gulp-terser
gulp-terser copied to clipboard
`module: true` Causes "SyntaxError in plugin 'terser': Unexpected token eof (undefined)"
Where Module.js
is an ES6 module,
gulp.src('Module.js')
.pipe(gulpTerser({module: true}))
.pipe(gulp.dest('public/js'))
results in
SyntaxError in plugin "terser"
Message:
Unexpected token: eof (undefined)
Details:
filename: 0
...
while
gulp.src('script.js')
.pipe(gulpTerser())
.pipe(gulp.dest('public/js'))
does not.
Upgrading terser to latest (5.5.1) appears to resolve.
You can try to configure Terser's ecma configuration, I think this error is caused by js syntax.
Still not work :
.pipe(terser({ecma: 2015}))
Still not work :
.pipe(terser({ecma: 2015}))
Does your code contain versions above 2015, and you have not compiled the code?
You can try to configure Terser's ecma configuration, I think this error is caused by js syntax.
The same Gulp task was working prior, and upgrading Terser solved the issue without changing the source script, so I don't believe it's a syntax error.
There's some conversation about this in Terser issues. I'm not using Ember, but it appears some package changes elsewhere caused issues in Terser. I suspect they resolved those, which is likely why upgrading Terser in this package fixed this issue for me.
Still not work :
.pipe(terser({ecma: 2015}))
Does your code contain versions above 2015, and you have not compiled the code?
Maybe! But my problem was elsewhere (a gulp task that remove all console.log resulting bad code). I end up using Terser directly from the command line. Did not tried gulp-terser after that sorry :(