{"id":13483421,"url":"https://github.com/egoist/package-size","last_synced_at":"2025-10-26T10:37:21.641Z","repository":{"id":14860803,"uuid":"77233895","full_name":"egoist/package-size","owner":"egoist","description":"Get the bundle size of an npm package.","archived":false,"fork":false,"pushed_at":"2022-06-18T15:55:45.000Z","size":554,"stargazers_count":423,"open_issues_count":12,"forks_count":26,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-28T16:04:22.483Z","etag":null,"topics":["bundle","webpack"],"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/egoist.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}},"created_at":"2016-12-23T15:28:04.000Z","updated_at":"2025-03-09T20:36:51.000Z","dependencies_parsed_at":"2022-07-14T06:50:32.680Z","dependency_job_id":null,"html_url":"https://github.com/egoist/package-size","commit_stats":null,"previous_names":[],"tags_count":43,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/egoist%2Fpackage-size","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/egoist%2Fpackage-size/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/egoist%2Fpackage-size/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/egoist%2Fpackage-size/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/egoist","download_url":"https://codeload.github.com/egoist/package-size/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247217174,"owners_count":20903008,"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":["bundle","webpack"],"created_at":"2024-07-31T17:01:11.086Z","updated_at":"2025-10-26T10:37:16.605Z","avatar_url":"https://github.com/egoist.png","language":"JavaScript","funding_links":[],"categories":["JavaScript","Packages"],"sub_categories":["Other"],"readme":"\u003cp align=\"center\"\u003e\n\u003ch1 align=\"center\"\u003epackage-size\u003c/h1\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://npmjs.com/package/package-size\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/package-size.svg?style=flat\" alt=\"NPM version\" /\u003e\u003c/a\u003e \u003ca href=\"https://npmjs.com/package/package-size\"\u003e\u003cimg src=\"https://img.shields.io/npm/dm/package-size.svg?style=flat\" alt=\"NPM downloads\" /\u003e\u003c/a\u003e \u003ca href=\"https://circleci.com/gh/egoist/package-size\"\u003e\u003cimg src=\"https://img.shields.io/circleci/project/egoist/package-size/master.svg?style=flat\" alt=\"Build Status\" /\u003e\u003c/a\u003e \u003ca href=\"https://github.com/egoist/donate\"\u003e\u003cimg src=\"https://img.shields.io/badge/$-donate-ff69b4.svg?maxAge=2592000\u0026amp;style=flat\" alt=\"donate\" /\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"./media/preview.gif\" alt=\"preview\" width=\"700\"\u003e\n\u003c/p\u003e\n\n## How does this work?\n\n1. Install the packages with yarn or npm in a temp directory\n2. Bundle the packages with webpack and get the bundle size\n3. Show you the bundle size and cache it by package version\n\n## Install\n\n```bash\nyarn global add package-size\n```\n\n## Usage\n\nThe package is bundled with Webpack.\n\n```bash\n# get the size of vue bundle\npackage-size vue\n\n# get the size of react+react-dom bundle\npackage-size react,react-dom\n\n# get the size of vue react+react-dom preact bundles\npackage-size vue react,react-dom preact\n\n# get the size of react+react-dom without using the cache\npackage-size react,react-dom --no-cache\n\n# get the size of file in current working directory\npackage-size ./dist/index.js\n# or a package in current working directory, explictly using `--cwd` flag\npackage-size vue --cwd\n\n# or event multiple versions for the same package!\npackage-size react@0.10 react@0.14 react@15\n\n# save results to file system in JSON format\n# defaults to ./package-size-output.json\npackage-size cherow --output\n# or custom path\npackage-size cherow --output stats.json\n\n# analyze bundle with webpack-bundle-analyzer\npackage-size cherow --analyze\n# analyze bundle with webpack-bundle-analyzer on a different port\npackage-size cherow --analyze --port 9000\n```\n\n## API\n\n```js\nconst getSizes = require('package-size')\n\ngetSizes('react,react-dom', options)\n  .then(data =\u003e {\n    console.log(data)\n    //=\u003e\n    {\n      name: 'react,react-dom',\n      size: 12023, // in bytes\n      minified: 2342,\n      gzipped: 534,\n      versionedName: 'react@16.0.0,react-dom@16.0.0'\n    }\n  })\n```\n\n### options\n\n#### sort\n\nType: `boolean`\u003cbr\u003e\nDefault: `false`\n\nSort packages in size (from small to large).\n\n#### cwd\n\nType: `boolean`\u003cbr\u003e\nDefault: `false`\n\nResolve modules in current working directory instead of a cache folder. Relative path will set `cwd` to `true` by default.\n\n#### externals\n\nType: `string` or `Array\u003cstring|RegExp\u003e`\u003cbr\u003e\nDefault: `undefined`\n\nThe package to exclude from bundled file, for example, to get the bundle size of `styled-jsx/style` we need to exclude `react`:\n\n```bash\npackage-size styled-jsx/style --externals react\n```\n\nNote that if some item in `externals` is provided as string, it will be wrapped in a regular expression. For example: `react` is treated as `/^react$/`\n\n#### cache\n\nType: `boolean`\u003cbr\u003e\nDefault: `true`\n\nIf `cache` is set to `false`, then package-size will not use cached build sizes. To use this from the CLI, pass `--no-cache` as an argument.\n\n#### target\n\nType: `string`\u003cbr\u003e\nDefault: `browser`\nValues: `browser` `node`\n\nBuild target. In `node` target, all node_modules will be excluded and output format is set to CommonJS.\n\n#### registry\n\nType: `string`\u003cbr\u003e\nDefault: `undefined`\n\nnpm registry to install the package from. By default it uses the default npm registry.\n\n#### resolve\n\nType: `string` `string[]`\u003cbr\u003e\nDefault: `undefined`\n\nExtra folders to resolve local node_modules from.\n\n## Contributing\n\n1. Fork it!\n2. Create your feature branch: `git checkout -b my-new-feature`\n3. Commit your changes: `git commit -am 'Add some feature'`\n4. Push to the branch: `git push origin my-new-feature`\n5. Submit a pull request :D\n\n## Author\n\n**package-size** © [EGOIST](https://github.com/egoist), Released under the [MIT](https://egoist.mit-license.org/) License.\u003cbr\u003e\nAuthored and maintained by EGOIST with help from contributors ([list](https://github.com/egoist/package-size/contributors)).\n\n\u003e [egoist.moe](https://egoist.moe) · GitHub [@egoist](https://github.com/egoist) · Twitter [@_egoistlily](https://twitter.com/_egoistlily)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fegoist%2Fpackage-size","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fegoist%2Fpackage-size","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fegoist%2Fpackage-size/lists"}