8 |
9 | - ⚖️ Find the cost of adding a new dependency to your project
10 | - 🕗 Save yourself time and disk space with this web app
11 | - 📈 Detect javascript bloat over time with a chart
12 | - 🛡️ Get a badge/shield for your README
13 | - 📡 Fetch size from json API to integrate into any tool
14 |
15 | *...as seen on [AWS Developer Tools Blog](https://aws.amazon.com/blogs/developer/how-we-halved-the-publish-size-of-modular-aws-sdk-for-javascript-clients/) and [npm weekly](https://medium.com/npm-inc/87f3bd77529#1883) and [ponyfoo weekly](https://ponyfoo.com/weekly/111/how-css-works-integration-testing-angular-6-optimizing-react-and-the-future-of-javascript) and [habr](https://habr.com/company/zfort/blog/354060/) and [rwpod](https://www.rwpod.com/posts/2018/04/23/podcast-06-16.html) and [wolf report](https://michael-wolfenden.github.io/2018/04/20/april-20th-2018/) and [the changelog](https://changelog.com/news/find-the-cost-of-adding-a-new-dependency-to-your-project-gbj6) and all over twitter*
16 |
17 | ## What is the purpose?
18 |
19 | Package Phobia reports the size of an npm package *before* you install it, and records the size over time.
20 |
21 | This is useful for inspecting potential `dependencies` or `devDependencies` without using up precious disk space or waiting minutes for `npm install`. Ain't nobody got time for dat.
22 |
23 | Results are saved so the first person might wait a bit to view package size, but everyone else gets to see the results instantly!
24 |
25 | ## [Demo](https://packagephobia.com)
26 |
27 | A good use case might be comparing test runners, web frameworks, or even bundlers. Click one of the links below to see Package Phobia in action!
28 |
29 | - Test Harnesses: [tap](https://packagephobia.com/result?p=tap) vs [tape](https://packagephobia.com/result?p=tape)
30 | - Web Frameworks: [express](https://packagephobia.com/result?p=express) vs [micro](https://packagephobia.com/result?p=micro)
31 | - JavaScript Bundlers: [webpack](https://packagephobia.com/result?p=webpack) vs [rollup](https://packagephobia.com/result?p=rollup)
32 | - Task Runners: [grunt](https://packagephobia.com/result?p=grunt) vs [gulp](https://packagephobia.com/result?p=gulp)
33 | - HTTP Requests: [request](https://packagephobia.com/result?p=request) vs [node-fetch](https://packagephobia.com/result?p=node-fetch)
34 | - Glob Patterns: [glob](https://packagephobia.com/result?p=glob) vs [tiny-glob](https://packagephobia.com/result?p=tiny-glob)
35 | - Arguments: [yargs](https://packagephobia.com/result?p=yargs) vs [arg](https://packagephobia.com/result?p=arg)
36 | - Site Generators: [gatsby](https://packagephobia.com/result?p=gatsby) vs [next](https://packagephobia.com/result?p=next)
37 | - Type Checkers: [typescript](https://packagephobia.com/result?p=typescript) vs [flow-bin](https://packagephobia.com/result?p=flow-bin)
38 | - Linters: [eslint](https://packagephobia.com/result?p=eslint) vs [jslint](https://packagephobia.com/result?p=jslint)
39 | - Color Formatters: [chalk](https://packagephobia.com/result?p=chalk) vs [picocolors](https://packagephobia.com/result?p=picocolors)
40 | - Command Line Interfaces: [@angular/cli](https://packagephobia.com/result?p=%40angular%2Fcli) vs [@babel/cli](https://packagephobia.com/result?p=%40babel%2Fcli)
41 | - Desktop Frameworks: [nw](https://packagephobia.com/result?p=nw) vs [electron](https://packagephobia.com/result?p=electron)
42 | - Headless Browsers: [puppeteer](https://packagephobia.com/result?p=puppeteer) vs [chrome-aws-lambda](https://packagephobia.com/result?p=chrome-aws-lambda)
43 | - Package Managers: [npm](https://packagephobia.com/result?p=npm) vs [yarn](https://packagephobia.com/result?p=yarn)
44 |
45 | ## API
46 |
47 | If you would like to use the Package Phobia API in your project, please create a PR modifying [API Users](https://github.com/styfle/packagephobia/blob/main/API.md#users).
48 |
49 | See [API.md](https://github.com/styfle/packagephobia/blob/main/API.md) for more usage details.
50 |
51 | ## Prior Art
52 |
53 | Package Phobia is inspired by [Bundle Phobia](https://github.com/pastelsky/bundlephobia) and [Cost Of Modules](https://github.com/siddharthkp/cost-of-modules).
54 |
55 | ## How is this different?
56 |
57 | - [Package Phobia](https://packagephobia.com) **THIS TOOL** web app that reports the install size of a package over time.
58 | - [Bundle Phobia](https://bundlephobia.com) web app that reports the size after webpack bundles the package over time.
59 | - [Bundle.js](https://bundlejs.com) web app that reports the size after esbuild bundles the custom code snippet.
60 | - [Pkg-Size](https://pkg-size.dev) web app that reports the size after esbuild bundles one or more packages.
61 | - [Cost Of Modules](https://github.com/siddharthkp/cost-of-modules) cli that reports the size of your currently installed packages.
62 | - [Badge Size](https://github.com/ngryman/badge-size) badge service that reports the gzip size of a single file from a package as svg.
63 | - [Size Limit](https://github.com/ai/size-limit) cli that fails if the bundled (or non-bundled) size of your app is too large.
64 | - [Bundle Size](https://github.com/siddharthkp/bundlesize) cli that fails CI if a file's size is too large.
65 | - [Package Size](https://github.com/egoist/package-size) cli that compares the bundle size of multiple packages.
66 | - [npm Size](https://github.com/egoist/npm-size) cli that compares the npm install size of multiple packages.
67 | - [Require So Slow](https://github.com/ofrobots/require-so-slow) cli that traces the time of each `require` module in a node.js app.
68 | - [Why Bundled?](https://github.com/d4rkr00t/whybundled) cli that uses webpack stats to show your number of imports and package size.
69 | - [Do you even lift?](https://github.com/npm/do-you-even-lift) - cli that reports size after rollup bundles the package via npm team.
70 | - [Import Cost](https://github.com/wix/import-cost) extension (and cli) that displays package size inline in the editor.
71 | - [npm Download Size](https://github.com/arve0/npm-download-size) web app that reports the download size (network traffic) of a package.
72 | - [npm Download Size cli](https://github.com/arve0/npm-download-size-cli) cli that reports the download size (network traffic) of a package.
73 | - [Build Size](https://github.com/Daniel15/BuildSize) - GitHub App that comments on a PR with the size of your build artifacts
74 | - [Pkg Size](http://pkgsize.com) - web app that displays package size and file count over time (static data only)
75 | - [BundleWatch](https://github.com/bundlewatch/bundlewatch) - cli that checks if your bundle exceeds a specific size and also tracks increase
76 | - [PackWatch](https://github.com/mcataford/packwatch) - cli that checks if your package tarball exceeds a specific size and also tracks increase
77 |
78 | ## Why is the size different than size on disk?
79 |
80 | Did you install a package and compare the size on disk with the size reported on Package Phobia?
81 |
82 | This number will likely be different because Package Phobia doesn't know anything about your hard drive so it can't predict how blocks are allocated.
83 |
84 | Packages are known to contain many small `.js` files which can actually use up a lot of disk space, more than if there was one large, contiguous file.
85 |
86 | See [this question](https://superuser.com/q/66825/27229) for more details.
87 |
88 | ## What are the long term goals?
89 |
90 | Ideally, this information could be listed on npmjs.com, npms.io, or bundlephobia.com.
91 |
92 | Below are the relevant feature requests for each website.
93 |
94 | - [GitHub issue for bundlephobia.com](https://github.com/pastelsky/bundlephobia/issues/40)
95 | - [GitHub issue for npmjs.com](https://github.com/npm/www/issues/197)
96 | - [GitHub issue for npms.io](https://github.com/npms-io/npms-www/issues/219)
97 | - [GitHub issue for staticgen.com](https://github.com/netlify/staticgen/issues/359)
98 | - [GitHub issue for cost-of-modules](https://github.com/siddharthkp/cost-of-modules/issues/50)
99 | - [GitHub issue for npm-cli](https://github.com/npm/npm/issues/20427)
100 | - [GitHub issue for bundlesize](https://github.com/siddharthkp/bundlesize/issues/205)
101 | - [GitHub issue for npmgraph.an](https://github.com/anvaka/npmgraph.an/issues/25)
102 |
103 | Hopefully, this would lead to publishers taking notice of their bloated packages such as the following:
104 |
105 | - [micro is not micro](https://github.com/zeit/micro/issues/234)
106 | - [ava is not minimal](https://github.com/avajs/ava/issues/1622)
107 | - [typescript has doubled in size since v2.0.0](https://github.com/Microsoft/TypeScript/issues/23339)
108 | - [bundlesize is 10x larger after npm install since v0.14.0](https://github.com/siddharthkp/bundlesize/issues/213)
109 | - [jquery@3.3.0 accidentally adds 300 dependencies](https://twitter.com/styfle/status/985955164573065217)
110 | - [socket.io is 6x smaller](https://twitter.com/styfle/status/986224072882380802)
111 | - [serve@7.0.0 is 3x smaller](https://twitter.com/styfle/status/1001901854417178624)
112 | - [webpack-cli@3.0.0 is 4x smaller](https://twitter.com/styfle/status/1006605750981021697)
113 | - [v8n@1.1.1 is 11x smaller](https://twitter.com/styfle/status/1022433043498364931)
114 | - [now@13.0.0-canary.6 is 2x smaller](https://twitter.com/styfle/status/1064512498706116617)
115 | - [typescript@5.0.0-beta is 41% smaller](https://twitter.com/styfle/status/1619058702753071105)
116 |
117 | ## npm dependencies in the media
118 |
119 | I'm not the first one to notice npm packages are snowballing into bloated dependencies of dependencies.
120 |
121 | Below are some other users who comically point out this JS bloat.
122 |
123 | | [thomasfuchs](https://twitter.com/thomasfuchs/status/977541462199029760)
124 | | [ben_a_adams](https://twitter.com/ben_a_adams/status/979358943561609216)
125 | | [devrant](https://devrant.com/rants/760537/heaviest-objects-in-the-universe)
126 | | [turnoff.us](https://turnoff.us/geek/npm-install/)
127 | | [styfle](https://twitter.com/styfle/status/968180698149539841)
128 | | [davej](https://github.com/npm/npm/issues/10361)
129 | | [FredyC](https://github.com/yarnpkg/yarn/issues/2088)
130 | | [tomitrescak](https://github.com/npm/npm/issues/12515)
131 | | [maybekatz](https://twitter.com/maybekatz/status/988893800054456320)
132 | | [hichaelmart](https://twitter.com/hichaelmart/status/988882864270962688)
133 | | [brad_frost](https://twitter.com/brad_frost/status/996014341592961025)
134 | | [Bryan_Chapel](https://twitter.com/Bryan_Chapel/status/1002680482159648769)
135 | | [getabitlit](https://twitter.com/getabitlit/status/1013524294394003456)
136 | | [iamdevloper](https://twitter.com/iamdevloper/status/1013767672369242112)
137 | | [rickhanlonii](https://twitter.com/rickhanlonii/status/1062319416107560961)
138 | |
139 |
140 | ## Contributing
141 |
142 | See [CONTRIBUTING.md](https://github.com/styfle/packagephobia/blob/main/CONTRIBUTING.md) and [CODE_OF_CONDUCT.md](https://github.com/styfle/packagephobia/blob/main/CODE_OF_CONDUCT.md) before you start writing any code
143 |
144 | ## Sponsors
145 |
146 | - Web hosting sponsored by [vercel.com](https://vercel.com/?utm_source=packagephobia)
147 | - Database sponsored by [upstash.com](https://upstash.com/?ref=packagephobia)
148 |
149 | ## Author
150 |
151 | Developed by [styfle](https://styfle.dev)
152 |
--------------------------------------------------------------------------------
/api/index.ts:
--------------------------------------------------------------------------------
1 | import { handler } from '../src/server';
2 |
3 | export default handler;
4 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "packagephobia",
3 | "private": true,
4 | "engines": {
5 | "node": "22.x"
6 | },
7 | "scripts": {
8 | "prettier": "prettier \"./**/*.ts\" \"./**/*.tsx\" --write",
9 | "git-pre-commit": "npm run prettier && git add -A",
10 | "lint": "npm run prettier && git diff --exit-code",
11 | "test": "tsc && rm -f test/hardlink/link && ln test/hardlink/orig.txt test/hardlink/link && node --test ./dist/test/**/*.test.js"
12 | },
13 | "repository": "styfle/packagephobia",
14 | "author": "styfle",
15 | "license": "MIT",
16 | "dependencies": {
17 | "badgen": "^3.2.3",
18 | "ioredis": "^5.4.1",
19 | "lru-cache": "^10.2.0",
20 | "react": "^18.2.0",
21 | "react-dom": "^18.2.0",
22 | "semver": "^7.6.0"
23 | },
24 | "devDependencies": {
25 | "@types/node": "^20.12.7",
26 | "@types/react": "^18.2.79",
27 | "@types/react-dom": "^18.2.25",
28 | "@types/semver": "^7.5.8",
29 | "npm": "^10.4.0",
30 | "prettier": "^3.2.5",
31 | "typescript": "^5.4.5"
32 | },
33 | "packageManager": "npm@10.9.0"
34 | }
35 |
--------------------------------------------------------------------------------
/public/android-chrome-192x192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/styfle/packagephobia/8a62f75902b9e089ebd10053ae2568041bcd29be/public/android-chrome-192x192.png
--------------------------------------------------------------------------------
/public/android-chrome-512x512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/styfle/packagephobia/8a62f75902b9e089ebd10053ae2568041bcd29be/public/android-chrome-512x512.png
--------------------------------------------------------------------------------
/public/apple-touch-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/styfle/packagephobia/8a62f75902b9e089ebd10053ae2568041bcd29be/public/apple-touch-icon.png
--------------------------------------------------------------------------------
/public/favicon-16x16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/styfle/packagephobia/8a62f75902b9e089ebd10053ae2568041bcd29be/public/favicon-16x16.png
--------------------------------------------------------------------------------
/public/favicon-32x32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/styfle/packagephobia/8a62f75902b9e089ebd10053ae2568041bcd29be/public/favicon-32x32.png
--------------------------------------------------------------------------------
/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/styfle/packagephobia/8a62f75902b9e089ebd10053ae2568041bcd29be/public/favicon.ico
--------------------------------------------------------------------------------
/public/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/styfle/packagephobia/8a62f75902b9e089ebd10053ae2568041bcd29be/public/logo.png
--------------------------------------------------------------------------------
/public/logo.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/public/robots.txt:
--------------------------------------------------------------------------------
1 | User-agent: AhrefsBot
2 | Disallow: /
3 | User-agent: Barkrowler
4 | Disallow: /
5 | User-agent: Bytespider
6 | Disallow: /
7 | User-agent: DotBot
8 | Disallow: /
9 | User-agent: GPTBot
10 | Disallow: /
11 | User-agent: marketgoo
12 | Disallow: /
13 | User-agent: MJ12bot
14 | Disallow: /
15 | User-agent: Moz dotbot
16 | Disallow: /
17 | User-agent: PetalBot
18 | Disallow: /
19 | User-agent: prerender
20 | Disallow: /
21 | User-agent: SEMrush
22 | Disallow: /
23 |
--------------------------------------------------------------------------------
/public/safari-pinned-tab.svg:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/public/site.webmanifest:
--------------------------------------------------------------------------------
1 | {
2 | "name": "Package Phobia",
3 | "short_name": "PP",
4 | "icons": [
5 | {
6 | "src": "/android-chrome-192x192.png",
7 | "sizes": "192x192",
8 | "type": "image/png"
9 | },
10 | {
11 | "src": "/android-chrome-512x512.png",
12 | "sizes": "512x512",
13 | "type": "image/png"
14 | }
15 | ],
16 | "start_url": "/?utm_source=a2hs",
17 | "theme_color": "#333333",
18 | "background_color": "#333333",
19 | "display": "standalone"
20 | }
21 |
--------------------------------------------------------------------------------
/src/browser.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { hydrate } from 'react-dom';
3 | import Index from './pages/index';
4 | import { containerId } from './util/constants';
5 |
6 | const app = Oops, "{props.resource}" does not exist.
16 |17 | Go Home You 18 |
19 |Oops, the package failed to install.
16 |17 | This can happen when there is no prebuilt binary for node@ 18 | {process.versions.node} or the install script requires CLIs like 19 | python/curl/etc. 20 |
21 |22 | Go Home 23 |
24 |25 | 29 | View Logs 30 | 31 |
32 ||
45 |
51 | |
61 |
62 | |
68 |
69 | |
75 |
29 | Find the cost of adding a new dev dependency to your project 30 |
31 | 32 |Oops, your package.json file could not be parsed.
14 |15 | Go Home You 16 |
17 |
40 | Copy Markdown:
41 |
42 |
53 |
A Tumbeast ate your package
59 | )} 60 | 61 | {exists ? ( 62 |