{"id":18458770,"url":"https://github.com/browserify/common-shakeify","last_synced_at":"2025-05-16T06:04:13.629Z","repository":{"id":40545815,"uuid":"100107226","full_name":"browserify/common-shakeify","owner":"browserify","description":"browserify tree shaking plugin using `common-shake`","archived":false,"fork":false,"pushed_at":"2024-12-21T10:00:31.000Z","size":160,"stargazers_count":104,"open_issues_count":14,"forks_count":18,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-08T16:01:57.304Z","etag":null,"topics":["browserify","browserify-plugin","commonjs","tree-shaking"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/common-shakeify","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/browserify.png","metadata":{"files":{"readme":"readme.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-08-12T11:10:07.000Z","updated_at":"2025-02-11T15:49:36.000Z","dependencies_parsed_at":"2025-01-27T16:38:20.318Z","dependency_job_id":"3fe40fd6-3663-4d6c-b15c-da7e675708fa","html_url":"https://github.com/browserify/common-shakeify","commit_stats":null,"previous_names":[],"tags_count":25,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/browserify%2Fcommon-shakeify","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/browserify%2Fcommon-shakeify/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/browserify%2Fcommon-shakeify/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/browserify%2Fcommon-shakeify/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/browserify","download_url":"https://codeload.github.com/browserify/common-shakeify/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254478163,"owners_count":22077675,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["browserify","browserify-plugin","commonjs","tree-shaking"],"created_at":"2024-11-06T08:19:58.620Z","updated_at":"2025-05-16T06:04:13.575Z","avatar_url":"https://github.com/browserify.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# common-shakeify\n\nbrowserify tree shaking plugin based on [common-shake](https://github.com/goto-bus-stop/common-shake), the CommonJS tree shaker originally by [@indutny](https://github.com/indutny).\n\nComments out unused exports from CommonJS modules.\n\nWith input files:\n\n```js\n// math.js\nexports.min = function (a, b) { return a \u003c b ? a : b }\nexports.max = function (a, b) { return a \u003c b ? b : a }\n\n// app.js\nvar math = require('./math')\nconsole.log(math.max(10, 20))\n```\n\nThis plugin will rewrite the files to:\n\n```js\n// math.js\n/* common-shake removed: exports.min = */ void function (a, b) { return a \u003c b ? a : b }\nexports.max = function (a, b) { return a \u003c b ? b : a }\n\n// app.js\nvar math = require('./math')\nconsole.log(math.max(10, 20))\n```\n\nUse a minifier on the output to remove the exports entirely.\n\n## Install\n\n```bash\nnpm install --save-dev common-shakeify\n```\n\n## Usage\n\nWith the browserify cli:\n\n```bash\nbrowserify -p common-shakeify /my/app.js \u003e bundle.js\n# Minify\nuglify-js bundle.js --compress \u003e bundle.min.js\n```\n\nWith the browserify Node API:\n\n```js\nvar commonShake = require('common-shakeify')\n\nvar b = browserify({ entries: '/my/app.js' })\n  .plugin(commonShake, { /* options */ })\n  .bundle()\n\n// Minify \u0026 save\nvar uglify = require('minify-stream')\nb\n  .pipe(uglify())\n  .pipe(fs.createWriteStream('bundle.min.js'))\n```\n\nNote that using a minifier transform like uglifyify doesn't eliminate the commented-out exports.\nTransforms run _before_ common-shakeify, so you have to use a minifier on the final bundle to remove the unused exports.\n\n## Options\n\n### `verbose`, `v`\n\nWhen true, print messages to stderr when exports are deleted, or the tree-shaker bails out on a module.\nDefault false.\nThe `verbose` flag only works when no custom handlers are passed, so if you're using eg. a custom `onExportDelete` you have to print these messages manually.\n\n```bash\n$ browserify -p [ common-shakeify -v ] app.js \u003e bundle.js\ncommon-shake: removed `decode` in node_modules/vlq/dist/vlq.js:10:7\ncommon-shake: bailed out: `module.exports` assignment in node_modules/process-nextick-args/index.js:20:3\n```\n\n### `onExportDelete(filename, exportName)`\n\nHandler called for every exported identifier that is being removed.\n`filename` is the path to the file that exports the identifier. `exportName` is the name of the identifier. Return false to bail and keep the identifier.\n\n### `onModuleBailout(module, reasons)`\n\nHandler called when a module cannot be tree-shaked for some reason.\n`module` is the [Module object from common-shake](https://github.com/indutny/common-shake/blob/master/lib/shake/module.js).\n`reasons` is an array of reasons that caused this module to be deoptimised.\n\n### `onGlobalBailout(reasons)`\n\nHandler called when tree-shaking is skipped entirely, usually because there is a dynamic `require` call in the source.\n`reasons` is an array of reasons for skipping tree-shaking.\n\n### `ecmaVersion`\n\nParse with this ecmaVersion as interpreted by acorn. (default: 10)\n\n## License\n\n[MIT](./LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrowserify%2Fcommon-shakeify","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbrowserify%2Fcommon-shakeify","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrowserify%2Fcommon-shakeify/lists"}