ParseError: 'import' and 'export' may appear only with 'sourceType: module'
binarykitchen opened this issue · comments
The other ticket confirmed ES2015 support is in, but still seeing the above error?
Isn't this a contradiction or do I have to transform code with babelify beforehand?
ES modules don't work with browserify (yet?). ref eg browserify/browserify#1186. All other new syntax does work.
Isn't this a contradiction or do I have to transform code with babelify beforehand?
Yep, you need to transform ES modules still—perhaps using babelify, or a faster option might be ascjsify which only deals with ES modules.
ah great thanks for pointing to ascjsify ...
... on a side note, would you be willing to add ascjsify to tinify's pipe? just an idea
i think transpiling ES2015+ code is best done with another tool—the es2015+ support in tinyify only means that it can parse it: it doesn't transpile, so if you give it ES2015, it also outputs ES2015
gotcha - fair enuff
Since this appeared pretty high in my google search, I'll offer a solution for other stumblers: https://github.com/mattdesl/esmify
browserify index.js -p esmify > bundle.js