uglifyjs: SyntaxError: Unexpected token: name (ZmodemError)
tsl0922 opened this issue · 4 comments
tsl0922 commented
I'm not sure whether this is a uglifyjs or zmodemjs issue, reproduce command:
./node_modules/.bin/uglifyjs node_modules/zmodem.js/dist/zmodem.devel.js
Parse error at node_modules/zmodem.js/dist/zmodem.devel.js:213,21
SyntaxError: Unexpected token: name (ZmodemError)
Error
at new JS_Parse_Error (eval at <anonymous> (.../ttyd/html/node_modules/uglify-js/tools/node.js:28:1), <anonymous>:1545:18)
FGasper commented
Last I checked, uglifyjs doesn’t grok some of the newer JS syntax in ES5/ES6. That’s why zmodemjs uses babel’s minifier.
tsl0922 commented
Thanks, got it work withbabelify
:
gulp.task('browserify', function () {
return browserify('./js/app.js')
.transform("babelify", {
presets: ["env"],
global: true,
ignore: /\/node_modules\/(?!zmodem.js\/)/
})
.bundle()
.pipe(fs.createWriteStream("./js/bundle.js"));
});
tsl0922 commented
@FGasper require('zmodem.js')
won't import Zmodem.Browser
, is this by design or should I change it to require('zmodem.js/dist/zmodem.devel')
?
UPDATE: require('zmodem.js/dist/zmodem.devel')
don't work too, but require('zmodem.js/src/zmodem_browser')
works.
FGasper commented
For now, try require('zmodem.js/dist/zmodem')
.
I figured that CommonJS includes would be more likely to be node.js. Maybe that’s worth rethinking.