Browserify tree-shaking plugin using the CommonJS tree shaker common-shake. Current stable version is 1.1.2, with no recent updates. It comments out unused CommonJS exports from modules during bundling, allowing a subsequent minifier to eliminate dead code. Key differentiator: unlike ES module tree-shakers, it supports CommonJS modules, which are prevalent in older or Node-based projects. Works only with browserify, not standalone.
npm install common-shakeifyNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Setup common-shakeify as a browserify plugin to tree-shake CommonJS modules and then minify the output.
Use a minifier on the final bundle (e.g., uglify-js) after browserify finishes, not as a transform.
Avoid dynamic requires (e.g., require(variable)) or use the onGlobalBailout callback to detect and handle.
Add your own console.log statements inside custom handlers if you want verbose output.
Set the ecmaVersion option to a higher number (e.g., 2020) if your code uses modern JS features.
Use exports.* = ... instead of module.exports = ... where possible.
Replace b.transform(commonShake) with b.plugin(commonShake)
Run `npm install --save-dev common-shakeify` and ensure the CLI flag is `-p common-shakeify`
Refactor to use exports.name = ... or use the onModuleBailout callback to handle
Set ecmaVersion option to e.g., 2020: `b.plugin(commonShake, { ecmaVersion: 2020 })`