[BUG] UglifyJs only works with ES5
See original GitHub issueDo you want to request a feature or report a bug?
bug
What is the current behavior?
When adding the UglifyJsPlugin
, I get an error like
ERROR in global.js from UglifyJs
Unexpected token: name (resolve) [global.js:1218,8]
where the problem like is like this:
function animationFrame() {
let resolve = null; // <--------------------------------- RIGHT HERE
const promise = new _promise2.default(function (r) {
return resolve = r;
});
window.requestAnimationFrame(resolve);
return promise;
}
If the current behavior is a bug, please provide the steps to reproduce.
This is a bug, because not all loaders convert JavaScript to strictly ES5 (which UglifyJs requires). For example, buble-loader
can convert JavaScript code for relatively new browser targets, which results in let
and const
statements that UglifyJs seems to crash on.
What is the expected behavior?
I should be able to stick buble-loader
into my Webpack project, and I should be able to use something like UglifyJsPlugin
to minify it.
However, this only works if one uses something like Babel to completely convert to ES5.
If this is a feature request, what is motivation or use case for changing the behavior?
Please mention other relevant information such as the browser version, Node.js version, webpack version and Operating System.
I’m on Webpack 3.4.1
.
Look how many people have had this problem: https://github.com/joeeames/WebpackFundamentalsCourse/issues/3
Issue Analytics
- State:
- Created 6 years ago
- Reactions:3
- Comments:7 (1 by maintainers)
@damsorian just replace
webpack/lib/optimize/UglifyJsPlugin
withbabili-webpack-plugin
. You have tonpm i babili-webpack-plugin --save-dev
first.in my case, this answer helped me.