Turn off inlining in optimization until UglifyJS issue is fixed. #264
Description
This minimization bug has been open for almost two months: mishoo/UglifyJS#2842. It has been referenced here elsewhere. The bug occurs when UglifyJS attempts to inline a call to a function with a variable of the same name as a variable in the calling function. Symptoms usually include "is not defined" or "assignment to constant variable".
In my experience, it's both easy to fall into and extremely time-consuming to diagnose.
I'd suggest turning inline: false
in Webpack 4 until this is fixed. From the comments, it looks like UglifyJS2 is suffering from a lack of contributors with the skills and bandwidth needed to deal with things like this.
All of the Webpack 4 blogging has been about "Just let us do it for you." IMHO, to fulfill the implied promise, I think you need to be reactive to component issues like this.
Related: optimization.minimize
and optimization.minimizer
(along with the rest of optimization
) need documenting.
For this particular issue, I'm using:
{
optimization:
minimizer: [
new UglifyJsPlugin({
parallel: true, // Webpack default
cache: true // Webpack default
uglifyOptions: {
/*
inlining is broken sometimes where inlined function uses the same variable name as inlining function.
See https://github.com/mishoo/UglifyJS2/issues/2842, https://github.com/mishoo/UglifyJS2/issues/2843
*/
compress: { inline:false },
},
})
],
}
This issue was moved from webpack/webpack#6798 by @evilebottnawi. Original issue was by @estaub.