{"id":13447094,"url":"https://github.com/siddharthkp/cost-of-modules","last_synced_at":"2025-05-14T09:11:10.208Z","repository":{"id":44895135,"uuid":"72152993","full_name":"siddharthkp/cost-of-modules","owner":"siddharthkp","description":"Find out which of your dependencies are slowing you down 🐢","archived":false,"fork":false,"pushed_at":"2023-07-24T21:35:43.000Z","size":485,"stargazers_count":2850,"open_issues_count":14,"forks_count":41,"subscribers_count":23,"default_branch":"main","last_synced_at":"2025-04-11T04:09:47.986Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/siddharthkp.png","metadata":{"files":{"readme":"README.md","changelog":null,"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}},"created_at":"2016-10-27T22:23:19.000Z","updated_at":"2025-04-05T17:11:23.000Z","dependencies_parsed_at":"2022-09-15T11:14:16.246Z","dependency_job_id":"e4626ee6-59f9-412c-b895-6bac0cbc91bd","html_url":"https://github.com/siddharthkp/cost-of-modules","commit_stats":{"total_commits":113,"total_committers":8,"mean_commits":14.125,"dds":"0.10619469026548678","last_synced_commit":"0a009d670a4e4fcb185b29979b5f58668664da4b"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/siddharthkp%2Fcost-of-modules","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/siddharthkp%2Fcost-of-modules/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/siddharthkp%2Fcost-of-modules/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/siddharthkp%2Fcost-of-modules/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/siddharthkp","download_url":"https://codeload.github.com/siddharthkp/cost-of-modules/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254110374,"owners_count":22016391,"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":[],"created_at":"2024-07-31T05:01:07.991Z","updated_at":"2025-05-14T09:11:10.187Z","avatar_url":"https://github.com/siddharthkp.png","language":"JavaScript","funding_links":[],"categories":["Packages","JavaScript","包","目录","Command-line apps"],"sub_categories":["Command-line apps","命令行程序","命令行应用"],"readme":"### Cost of modules\nFind out which of your dependencies is slowing you down\n\n\u0026nbsp;\n\n[![Build\nStatus](https://api.travis-ci.org/siddharthkp/cost-of-modules.svg?branch=master)](https://travis-ci.org/siddharthkp/cost-of-modules)\n[![npm](https://img.shields.io/npm/v/cost-of-modules.svg?maxAge=3600)](https://www.npmjs.com/package/cost-of-modules)\n[![npm](https://img.shields.io/npm/dt/cost-of-modules.svg?maxAge=3600)](https://www.npmjs.com/package/cost-of-modules)\n\n\u0026nbsp;\n\n#### Sponsor\n\n[![Sponsor](https://app.codesponsor.io/embed/LhLT2c31ydJzdLUuSR9f8mCA/siddharthkp/cost-of-modules.svg)](https://app.codesponsor.io/link/LhLT2c31ydJzdLUuSR9f8mCA/siddharthkp/cost-of-modules)\n\n\u0026nbsp;\n\n![Find out which of your dependencies is causing bloat](https://raw.githubusercontent.com/siddharthkp/cost-of-modules/master/screenshot.jpg)\n\n#### Install\n\n`npm install -g cost-of-modules`\n\n#### Usage\n\nRun `cost-of-modules` in the directory you are working in.\n\n#### Options\n\n`--less`  Show the biggest 10 modules\n\n`--yarn`  Use yarn instead of npm to install dependencies\n\n`--no-install`  Skip installation\n\n`--include-dev`  Include devDependencies as well - for 🚀 collaborator experience\n\n#### Show your support\n\n:star: this repo\n\n#### Motivation\n\nI recently published a npm module ([auto-install](https://github.com/siddharthkp/auto-install)) and I wanted to know how many bytes am I making people download before they can use it. Turns out, it was a whopping 30M!\n\n__More than space on disk, I want to optimise for install speed - setup is part of the user experience__\n\n--\n\nNow, there are 3 things that you can do to make your npm package smaller\n\n1. Make sure all your workflow tools are in `devDependencies` and not in `dependencies` These include your build tools, testing frameworks, etc. Only `dependencies` get installed when someone installs your package. (That being said, for better collaborator experience, you should optimise for both)\n\n2. Only include the files you need by using `files` in your `package.json` or by including a `.npmignore`. [More on that here.](https://docs.npmjs.com/files/package.json#files)\n\n3. Use packages which do the job and take the least amount of space. For example, I realised that I did not need `yargs`, I only needed their parser `yargs-parser` which is much smaller.\n\n4. Bonus: Bundle all your code together and strip out the functions that you don't use - I still have to try this out. This could be the most impactful one.\n\n--\n\nIn my case, the big size was because of # 3, the bunch of npm packages that I was using.\n\n__You can't fix what you can't measure__\n\nWith npm 2.x, it was easy to find how much space is each of your dependencies taking. You could just look at the size of each directory in `node_modules`\n\nWith npm 3, the packages are installed in flat manner, so [it isn't so straightforward](https://github.com/npm/npm/issues/10361).\n\nThat's the reason why I created this tool.\n\n--\n\n__Future__\n\nI would want to make this tool a pre-publish checklist.\n\n- [x] See the size of your `node_modules`\n- [ ] Include the size of your files\n- [ ] Check if `files` or `.npmignore` exists\n- [ ] Check if there are any `dev dependencies` that are specified as `dependencies` (tricky)\n- [ ] Compare size with the last release. Something like this:\n![Warning](https://raw.githubusercontent.com/siddharthkp/cost-of-modules/master/warning.png)\n\n\n#### License\n\nMIT © [siddharthkp](https://github.com/siddharthkp)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsiddharthkp%2Fcost-of-modules","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsiddharthkp%2Fcost-of-modules","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsiddharthkp%2Fcost-of-modules/lists"}