Unexpected token import after upgrade from phoenix 1.2 to 1.3

After upgrading to phoenix 1.3 fro 1.2 (elixir 1.5.1) i get unexpected token import on import ‘phoenix_html’ in app.js. I followed the upgrade guide. The app is working otherwise.

package.json

   {
      "repository": {},
      "license": "MIT",
      "scripts": {
        "deploy": "brunch build --production",
        "watch": "brunch watch --stdin"
      },
      "dependencies": {
        "phoenix": "file:../deps/phoenix",
        "phoenix_html": "file:../deps/phoenix_html"
      },
      "devDependencies": {
        "babel-brunch": "6.1.1",
        "brunch": "2.10.9",
        "clean-css-brunch": "2.10.0",
        "uglify-js-brunch": "2.10.0"
      }
    }

brunch config:

exports.config = {
  // See http://brunch.io/#documentation for docs.
  files: {
    javascripts: {
      joinTo: "js/app.js"
    },
    stylesheets: {
      joinTo: "css/app.css"
    },
    templates: {
      joinTo: "js/app.js"
    }
  },

  conventions: {
    assets: /^(static)/
  },

  // Phoenix paths configuration
  paths: {
    // Dependencies and current project directories to watch
    watched: ["static", "css", "js", "vendor"],
    // Where to compile files to
    public: "../priv/static"
  },

  // Configure your plugins
  plugins: {
    babel: {
      // Do not use ES6 compiler in vendor code
      ignore: [/vendor/]
    }
  },

  modules: {
    autoRequire: {
      "js/app.js": ["js/app"]
    }
  }
};

What am i doing wrong?

1 Like

I guess you followed this migration guide: https://gist.github.com/chrismccord/71ab10d433c98b714b75c886eff17357

The assets folder refactor section is too confusing, I was having the same problem as you so let’s hope is the same issue and you will be able to fix it.

The thing is that I have the js and css inside the assets/static folder, and they should be just under assets.

Just in case, remember that if you have an umbrella application your package.json depedencies have to change its relative path from “phoenix”: “file:…/deps/phoenix” to “phoenix”: "file:…/…/…/deps/phoenix"

Hope you can solve your problem.

See you!

1 Like