UNPKG

1.66 kBMarkdownView Raw
1<p align="center">
2 <br>
3 <br>
4 <img width="70%" src=".github/screenshot.png">
5 <br>
6 <a href="https://npm.im/pkg-size"><img src="https://badgen.net/npm/v/pkg-size"></a>
7 <a href="https://npm.im/pkg-size"><img src="https://badgen.net/npm/dm/pkg-size"></a>
8 <a href="https://packagephobia.now.sh/result?p=pkg-size"><img src="https://packagephobia.now.sh/badge?p=pkg-size"></a>
9 <br>
10 <br>
11 <i>Measure the size of your npm package distribution</i>
12</p>
13
14**⚡️ Try it in your npm package**
15
16```sh
17$ npx pkg-size
18```
19
20<sub>If you like this project, please star it & [follow me](https://github.com/privatenumber) to see what other cool projects I'm working on! ❤️</sub>
21
22## 🙋‍♂️ Why?
23- **🔍 Size analysis** Quickly determine the total size of what you're publishing to npm!
24- **🔥 Same behavior as npm `pack`/`publish`** Collects publish files as specified in your `package.json`!
25- **🙌 Gzip & Brotli** See how your files compress in addition to normal size!
26- **🤖 Node.js API** Integrate size checks to your CI via Node.js API
27
28## 🚀 Install
29```sh
30npm i pkg-size
31```
32
33## 🚦 Quick Usage
34```js
35const pkgSize = require('pkg-size');
36
37// Get package size data from current working directory
38const sizeData = await pkgSize();
39
40// Get package size data from a specific package path
41const sizeData = await pkgSize('/path/to/package');
42```
43
44## ⚙️ API
45```ts
46type FileEntry = {
47 path: string;
48 mode: number;
49 size: number;
50 sizeGzip: number;
51 sizeBrotli: number;
52};
53
54type PkgSizeData = {
55 pkgPath: string;
56 tarballSize: number;
57 files: FileEntry[];
58};
59
60function pkgSize(pkgPath?: string): Promise<PkgSizeData>;
61```