-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Webpack5 ES5 Terser compression configuration is incorrect #16135
Webpack5 ES5 Terser compression configuration is incorrect #16135
Comments
hm.. yeah, we defaults should be updated.. |
Has Webpack5 always had this problem? I've got other projects that don't have 'arrows:false' configured either, don't see why |
We handle ecma here https://github.com/webpack-contrib/terser-webpack-plugin/blob/master/src/index.js#L490, so I will fix it on the plugin side |
Check that all Terser configurations are ES5 compliant, |
Alternatively, it is recommended that the Terser compressor be compatible with an ESMA configuration of 5 without setting the arrows to False |
import { minify } from "terser";
var code = `
(function() {
var __webpack_exports__ = {};
var abc = {
data() {
return {
a: 2
};
}};
console.log(abc)
})();
`;
var result = await minify(code, { compress: { passes: 2 }, module: false, ecma: 5 }) // Webpack configuration of Terser
console.log(result.code); ➜ node test.mjs
console.log({data:()=>({a:2})}); |
I agree that at least the ecma option should be respected (ideally browserslist). |
@chenyulun Fix - webpack-contrib/terser-webpack-plugin#509 (swc affected too) + change ecma from 5 should enable more optimizations |
Anyway will be great if terser handle it too |
Bug report
What is the current behavior?
input code
output code
Webpack target should actively configure Terser's options.compress.arrows = False if ES5 is present
If the current behavior is a bug, please provide the steps to reproduce.
Error recurrence project
https://github.com/chenyulun/webpack5-test
What is the expected behavior?
// Hopefully there's no arrow function
Other relevant information:
webpack version: 5.74.0
Node.js version: v16.15.1
Operating System: macOS 12.3.1
Additional tools: null
The text was updated successfully, but these errors were encountered: