Is it possible to use ES6 modules in Google Chrome Extension Development?
I get 'unexpected token export' or 'unexpected token import'.
JavaScript in ECMAScript 6 supports modules which you may now use in Google Chrome since version 61.
To solve the "Uncaught SyntaxError Unexpected token 'export'" error, set the type of your <script /> tags to module , e.g. <script type="module" src="index. js"></script> . The type="module" attribute is supported in all modern browsers and allows us to use the ES6 modules syntax.
Well sort of, you can see here in the compatibility table for chrome that not everything is available. Chrome is good about adding ES6 features with each release but currently import is not supported.
http://kangax.github.io/compat-table/es6/
Now that said, you can use all ES6 features if you use a compiler like babel
https://babeljs.io/
Check out this answer for more info, note it is dated: Is it possible to use ES6 in a Chrome Extension?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With