import can't be used in chrome 61?

Viewed 7724

I'm trying to play ES6 features in the latest release version of chrome, that is chrome 61, and I met the error during using the import key word. Technically, import is used as following method but the console showed me errors:

import Mymodule from "Mymodule.js"

the console printed:

Uncaught SyntaxError: Unexpected identifier

I have already turn the following experimental features on:

chrome://flags/#enable-javascript-harmony
chrome://flags/#enable-module-scripts

and following off:

chrome://flags/#disable-javascript-harmony-shipping
2 Answers

"import" support is not yet natively included in Chrome, but is currently in development

https://www.chromestatus.com/feature/5684934484164608

Until then you would need to compile and bundle your code with something like Babel and Browserify or Webpack.

Update: As mentioned below by @neaumusic, this feature is part of Chrome 61. The What's New note references Paul Irish's Module-implementation as an example.

It would help to see your MyModule.js code, to see exactly what it is your module is exporting. This partially determines how you phrase your 'import' statements.

Related