Reputation: 29885
In the following code:
ROOTNS.ui.components.orgChart = (function () {
import PubSub from 'pubsub-js'
})();
I get the runtime error on the import statement of:
Uncaught SyntaxError: Unexpected identifier
My app is based on Chromium version 66, which supports the import statement, so what is wrong with the syntax?
Upvotes: 1
Views: 917
Reputation: 10428
Imports must be at the top of your script before any other code. ES6 modules don't work like other module systems where you can load modules conditionally.
import PubSub from 'pubsub-js'
ROOTNS.ui.components.orgChart = (function () {
// other code
})();
Upvotes: 1