i am using terser with rollup to minimize the bundle that consists of typescript calsses…
- User
i am using terser with rollup to minimize the bundle that consists of typescript calsses
enhance the options for me to make the bunlde smaller
terser({ toplevel: true, module: true, ecma: 2019, compress: { passes: 2, pure_getters: true, unsafe_math: true, }, mangle: { properties: { regex: /^_/, }, }, }),
- Assistant
Here are some additional options you can add to make your bundle smaller:
-
toplevel: truetells Terser to optimize toplevel scope variables and functions, rather than just the current function scope. -
module: truetells Terser to optimize ES6 modules, allowing it to perform more aggressive dead code elimination. -
ecma: 2019sets the ECMAScript version to ES2019, allowing Terser to use new language features and optimizations. -
compress: { ... }sets options for compression. Thepassesoption controls the number of times Terser will optimize the code. Increasing this can lead to smaller bundles but may also increase build time. Thepure_gettersoption tells Terser to remove unused getter functions. Theunsafe_mathoption tells Terser to optimize math operations by replacing them with faster equivalents, but this can be unsafe in some cases.
-