Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize package published to npm #257

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

metonym
Copy link

@metonym metonym commented Aug 25, 2024

Currently, the entire repository contents are published to NPM. The package can be optimized by excluding unnecessary files/folders/metadata when publishing to NPM.

Screenshot 2024-08-25 at 8 59 30 AM

The distributed package size can be optimized by using the package.json#files property. It's an allowlist of files or folders for publishing.

This PR proposes allowlisting dist and src folders. Note that some files are automatically included and do not need to be specified (e.g., README, LICENSE).

Running npm pack shows the following comparison.

Before

  1. On the main branch
  2. npm i; npm run build
  3. npm pack
npm notice name:          @vscode/codicons                        
npm notice version:       0.0.36                                  
npm notice filename:      vscode-codicons-0.0.36.tgz              
npm notice package size:  764.2 kB                                
npm notice unpacked size: 1.5 MB                                  
npm notice shasum:        b0d87610ffc3e3ca45c5f8e0d8e08713c16c13a8
npm notice integrity:     sha512-py9MnHtx7AjvF[...]OWu7elS+H67Nw==
npm notice total files:   502

After

  1. On this branch
  2. npm i; npm run build
  3. npm pack
npm notice name:          @vscode/codicons                        
npm notice version:       0.0.36                                  
npm notice filename:      vscode-codicons-0.0.36.tgz              
npm notice package size:  276.9 kB                                
npm notice unpacked size: 972.6 kB                                
npm notice shasum:        b6ad40e66d586dd253f3050b680fa6152d6d66f6
npm notice integrity:     sha512-i4CXMhE6/iCTk[...]wioFa7eoPksXQ==
npm notice total files:   474    

Result

Consequently, the size of the publish package (both packed/unpacked) can be dramatically reduced.

- npm notice package size:  764.2 kB                                
+ npm notice package size:  276.9 kB         

- npm notice unpacked size: 1.5 MB                           
+ npm notice unpacked size: 972.6 kB             

@hbons hbons self-requested a review September 26, 2024 14:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant