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

Reduce bundle size #47

Merged
merged 2 commits into from
Nov 2, 2024
Merged

Reduce bundle size #47

merged 2 commits into from
Nov 2, 2024

Conversation

simonmcallister0210
Copy link
Owner

@simonmcallister0210 simonmcallister0210 commented Nov 2, 2024

Context

Noticed the bundle was unusually big (~720kb). Assumed it must be because it's a hybrid package, but looking into it, it looks like it's because npm dependencies are included in the bundle 🤦 . Minifying the bundle would also help reduce the size too. I've done both here

I've also added a PR template because why not

Changes

  • Exclude npm dependencies from bundle
  • Minify bundle code
  • Add PR template

Testing

package size: 135.5 kB -> 16.4 kB
unpacked size: 721.7 kB -> 56.2 kB

Before:

simonmcallister@Simons-MBP cognito-srp-helper % npm publish --dry-run
npm WARN publish npm auto-corrected some errors in your package.json when publishing.  Please run "npm pkg fix" to address these errors.
npm WARN publish errors corrected:
npm WARN publish "repository" was changed from a string to an object
npm WARN publish "repository.url" was normalized to "git+https://github.com/simonmcallister0210/cognito-srp-helper.git"
npm notice 
npm notice 📦  [email protected]
npm notice === Tarball Contents === 
npm notice 10.9kB  LICENSE.md                        
npm notice 12.9kB  README.md                         
npm notice 342.8kB dist/cjs/index.js                 
npm notice 23B     dist/cjs/package.json             
npm notice 342.3kB dist/esm/index.js                 
npm notice 21B     dist/esm/package.json             
npm notice 1.2kB   dist/types/cognito-srp-helper.d.ts
npm notice 276B    dist/types/constants.d.ts         
npm notice 1.2kB   dist/types/errors.d.ts            
npm notice 89B     dist/types/index.d.ts             
npm notice 4.7kB   dist/types/types.d.ts             
npm notice 2.1kB   dist/types/utils.d.ts             
npm notice 3.1kB   package.json                      
npm notice === Tarball Details === 
npm notice name:          cognito-srp-helper                      
npm notice version:       2.3.0                                   
npm notice filename:      cognito-srp-helper-2.3.0.tgz            
npm notice package size:  135.5 kB                                
npm notice unpacked size: 721.7 kB                                
npm notice shasum:        5c016fcce82a27a899d89ef1d0b525a0c4b0767c
npm notice integrity:     sha512-BtAJOB/4Uxldo[...]BgSSuPXrUJKHQ==
npm notice total files:   13                                      
npm notice 
npm notice Publishing to https://registry.npmjs.org/ with tag latest and default access (dry-run)
+ [email protected]

After:

simonmcallister@Simons-MBP cognito-srp-helper % npm publish --dry-run                            
npm WARN publish npm auto-corrected some errors in your package.json when publishing.  Please run "npm pkg fix" to address these errors.
npm WARN publish errors corrected:
npm WARN publish "repository" was changed from a string to an object
npm WARN publish "repository.url" was normalized to "git+https://github.com/simonmcallister0210/cognito-srp-helper.git"
npm notice 
npm notice 📦  [email protected]
npm notice === Tarball Contents === 
npm notice 10.9kB LICENSE.md                        
npm notice 12.9kB README.md                         
npm notice 10.4kB dist/cjs/index.js                 
npm notice 23B    dist/cjs/package.json             
npm notice 9.3kB  dist/esm/index.js                 
npm notice 21B    dist/esm/package.json             
npm notice 1.2kB  dist/types/cognito-srp-helper.d.ts
npm notice 276B   dist/types/constants.d.ts         
npm notice 1.2kB  dist/types/errors.d.ts            
npm notice 89B    dist/types/index.d.ts             
npm notice 4.7kB  dist/types/types.d.ts             
npm notice 2.1kB  dist/types/utils.d.ts             
npm notice 3.1kB  package.json                      
npm notice === Tarball Details === 
npm notice name:          cognito-srp-helper                      
npm notice version:       2.3.0                                   
npm notice filename:      cognito-srp-helper-2.3.0.tgz            
npm notice package size:  16.4 kB                                 
npm notice unpacked size: 56.2 kB                                 
npm notice shasum:        268e91bf90db5f7e8beb2f577ce79d6df9d0ce14
npm notice integrity:     sha512-ZXLJ1A3iM8Eo7[...]Mxqwalpf96OuA==
npm notice total files:   13                                      
npm notice 
npm notice Publishing to https://registry.npmjs.org/ with tag latest and default access (dry-run)
+ [email protected]

@simonmcallister0210 simonmcallister0210 linked an issue Nov 2, 2024 that may be closed by this pull request
@simonmcallister0210 simonmcallister0210 marked this pull request as ready for review November 2, 2024 21:23
@simonmcallister0210 simonmcallister0210 merged commit 2a21513 into main Nov 2, 2024
2 checks passed
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.

Look into the bundle size
1 participant