segmentio / evergreen

🌲 Evergreen React UI Framework by Segment
https://evergreen.segment.com
MIT License
12.38k stars 830 forks source link

v7 npm package is way too big #1595

Closed brandongregoryscott closed 1 year ago

brandongregoryscott commented 1 year ago

It looks like something is incorrectly getting packaged up now, there's no way the distribution should be 500MB / ~5.6k files.

https://www.npmjs.com/package/evergreen-ui?activeTab=versions

image

It looks like the V7 pre-release package is also the same size:

https://www.npmjs.com/package/evergreen-ui/v/7.0.0 https://www.npmjs.com/package/evergreen-ui/v/7.0.0-0

brandongregoryscott commented 1 year ago

Alright, looks like npm pack --dry-run and yarn pack --dry-run work a little differently. npm pack --dry-run was showing the correct size / file listing...

➜  evergreen git:(master) ✗ npm pack && ls -l evergreen-ui-7.0.0.tgz 
npm notice === Tarball Details === 
npm notice name:          evergreen-ui                            
npm notice version:       7.0.0                                   
npm notice filename:      evergreen-ui-7.0.0.tgz                  
npm notice package size:  1.2 MB                                  
npm notice unpacked size: 6.6 MB                                  
npm notice shasum:        e792bac5e2028cc61286040bcd3ba04f2172cd04
npm notice integrity:     sha512-SLUpPAixFVnqk[...]D5yHn2zBCFbPQ==
npm notice total files:   1764                                    
npm notice 
evergreen-ui-7.0.0.tgz
-rw-r--r--  1 Brandon  staff  1203132 Jan 17 20:35 evergreen-ui-7.0.0.tgz

However, yarn pack --dry-run generates a much different tarball:

➜  evergreen git:(master) yarn pack --dry-run                      
yarn pack v1.22.17
success Wrote tarball to "/Users/Brandon/oss/fork/evergreen/evergreen-ui-v7.0.0.tgz".
✨  Done in 10.16s.
➜  evergreen git:(master) ✗ ls -l evergreen-ui-v7.0.0.tgz 
-rw-r--r--  1 Brandon  staff  81265232 Jan 17 20:32 evergreen-ui-v7.0.0.tgz

The .tgz generated by yarn is almost 81 MB, while the npm generated by npm is the expected size - 1.2 MB. I think this change is from the addition of the !**/*.test.js and !**/*.stories.js lines in package.json > files

This was certainly not the intended effect, so I'll open up a PR to remove those!

brandongregoryscott commented 1 year ago

Related: probably need to look into https://github.com/ai/size-limit/ and updating our configuration to catch something like this in the future 😓