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

Big increase in npm package size #108

Closed
mrchrisadams opened this issue Oct 3, 2022 · 5 comments
Closed

Big increase in npm package size #108

mrchrisadams opened this issue Oct 3, 2022 · 5 comments
Labels
Milestone

Comments

@mrchrisadams
Copy link
Member

We seem to have a muuuch bigger bundle size than before, and I am not sure what caused it.

It would be nice to not have this, and I suspect this is related to bundling some more data into the library by default.

It would be useful to see how people are using it, and which parts it might make sense to strip out to keep the npm bundle size reasonable.

@mrchrisadams mrchrisadams added this to the 0.12.0 milestone Oct 3, 2022
@soulgalore
Copy link
Contributor

Hi @mrchrisadams is that the main branch? I did try with running npm pack and it looks like data/fixtures are included. I think adding data/fixtures to .npmignore will fix that.

@Ryuno-Ki
Copy link

Ryuno-Ki commented Oct 3, 2022

Alternatively, be explicit by using files property in package.json.

@mrchrisadams
Copy link
Member Author

ah, thanks @soulgalore - I was hunting around for the command to see the generated package, and npm pack was exactly the thing I was after.

Also, yikes:

$ npm pack


npm notice
npm notice 📦  @tgwf/[email protected]
npm notice === Tarball Contents === 
npm notice 870B    .all-contributorsrc                                      
npm notice 225B    .esbuild.browser.js                                      
npm notice 908B    .esbuild.esm.js                                          
npm notice 344B    .esbuild.node.js                                         
npm notice 8B      .eslintignore                                            
npm notice 183B    .gitpod.yml                                              
npm notice 6.2kB   CHANGELOG.md                                             
npm notice 12.0kB  LICENSE                                                  
npm notice 562B    NOTICE                                                   
npm notice 5.1kB   README.md                                                
npm notice 91B     data/.prettierignore                                     
npm notice 7.5kB   data/co2-intensities-ember-2020.csv                      
npm notice 2.8kB   data/co2-intensities-ember-2021.csv                      
npm notice 7.1kB   data/fixtures/countries.csv
npm notice 187.2kB data/fixtures/tgwf.har
npm notice 16.6MB  data/fixtures/url2green.test.db
npm notice 329B    data/fixtures/url2green.test.json
npm notice 54B     data/fixtures/url2green.test.json.gz
npm notice 3.6kB   data/functions/generate_ember_average_intensities_co2.js
npm notice 3.9kB   data/functions/generate_marginal_co2.js                  
npm notice 782B    data/generate_co2_constants.py
npm notice 8.7kB   data/IFI_Default_Grid_Factors_2021_v3.1_unfccc.csv       
npm notice 17.5kB  data/Lean-ICT-Materials-1byte-Model-2018.xlsx            
npm notice 103.8kB data/Lean-ICT-Materials-Forecast-Model-2018.xlsx         
npm notice 1.7kB   data/output/average-intensities-ember-2021.js            
npm notice 20.8kB  data/output/average-intensities-ember-2021.json          
npm notice 3.5kB   data/output/marginal-intensities-unfccc-2021.js          
npm notice 85.6kB  data/output/marginal-intensities-unfccc-2021.json        
npm notice 1.2kB   data/utils/getCountryCodes.js                            
npm notice 1.1kB   data/utils/mapCountries.js                               
npm notice 1.3kB   data/utils/parseCSVRow.js                                
npm notice 1.9kB   dist/cjs/1byte.js                                        
npm notice 3.0kB   dist/cjs/1byte.js.map                                    
npm notice 1.3kB   dist/cjs/1byte.test.js                                   
npm notice 923B    dist/cjs/1byte.test.js.map                               
npm notice 5.3kB   dist/cjs/co2.js                                          
npm notice 8.0kB   dist/cjs/co2.js.map                                      
npm notice 12.3kB  dist/cjs/co2.test.js                                     
npm notice 18.5kB  dist/cjs/co2.test.js.map                                 
npm notice 1.0kB   dist/cjs/constants/file-size.js                          
npm notice 306B    dist/cjs/constants/file-size.js.map                      
npm notice 1.3kB   dist/cjs/constants/index.js                              
npm notice 251B    dist/cjs/constants/index.js.map                          
npm notice 2.9kB   dist/cjs/data/average-intensities-ember-2021.min.js      
npm notice 3.1kB   dist/cjs/data/average-intensities-ember-2021.min.js.map  
npm notice 4.7kB   dist/cjs/data/marginal-intensities-unfccc-2021.min.js    
npm notice 6.6kB   dist/cjs/data/marginal-intensities-unfccc-2021.min.js.map
npm notice 1.0kB   dist/cjs/helpers/index.js                                
npm notice 305B    dist/cjs/helpers/index.js.map                            
npm notice 2.5kB   dist/cjs/hosting-api.js                                  
npm notice 2.5kB   dist/cjs/hosting-api.js.map                              
npm notice 2.1kB   dist/cjs/hosting-api.test.js                             
npm notice 2.1kB   dist/cjs/hosting-api.test.js.map                         
npm notice 1.8kB   dist/cjs/hosting-database.node.test.js                   
npm notice 1.5kB   dist/cjs/hosting-database.node.test.js.map               
npm notice 2.7kB   dist/cjs/hosting-json.node.js                            
npm notice 3.2kB   dist/cjs/hosting-json.node.js.map                        
npm notice 2.3kB   dist/cjs/hosting-json.node.test.js                       
npm notice 2.2kB   dist/cjs/hosting-json.node.test.js.map                   
npm notice 3.1kB   dist/cjs/hosting-node.js                                 
npm notice 3.7kB   dist/cjs/hosting-node.js.map                             
npm notice 1.6kB   dist/cjs/hosting.js                                      
npm notice 554B    dist/cjs/hosting.js.map                                  
npm notice 3.4kB   dist/cjs/hosting.test.js                                 
npm notice 3.9kB   dist/cjs/hosting.test.js.map                             
npm notice 1.8kB   dist/cjs/index-node.js                                   
npm notice 529B    dist/cjs/index-node.js.map                               
npm notice 2.0kB   dist/cjs/index.js                                        
npm notice 647B    dist/cjs/index.js.map                                    
npm notice 27B     dist/cjs/package.json                                    
npm notice 6.7kB   dist/cjs/sustainable-web-design.js                       
npm notice 13.8kB  dist/cjs/sustainable-web-design.js.map                   
npm notice 3.8kB   dist/cjs/sustainable-web-design.test.js                  
npm notice 5.1kB   dist/cjs/sustainable-web-design.test.js.map              
npm notice 1.0kB   dist/esm/1byte.js                                        
npm notice 360B    dist/esm/1byte.test.js                                   
npm notice 4.0kB   dist/esm/co2.js                                          
npm notice 11.0kB  dist/esm/co2.test.js                                     
npm notice 117B    dist/esm/constants/file-size.js                          
npm notice 62B     dist/esm/constants/index.js                              
npm notice 1.8kB   dist/esm/data/average-intensities-ember-2021.min.js      
npm notice 3.6kB   dist/esm/data/marginal-intensities-unfccc-2021.min.js    
npm notice 85B     dist/esm/helpers/index.js                                
npm notice 1.3kB   dist/esm/hosting-api.js                                  
npm notice 1.1kB   dist/esm/hosting-api.test.js                             
npm notice 810B    dist/esm/hosting-database.node.test.js                   
npm notice 1.2kB   dist/esm/hosting-json.node.test.js                       
npm notice 275B    dist/esm/hosting.js                                      
npm notice 2.2kB   dist/esm/hosting.test.js                                 
npm notice 390B    dist/esm/index.js                                        
npm notice 25B     dist/esm/package.json                                    
npm notice 5.2kB   dist/esm/sustainable-web-design.js                       
npm notice 2.8kB   dist/esm/sustainable-web-design.test.js                  
npm notice 15.4kB  dist/iife/index.js                                       
npm notice 58.7kB  dist/iife/index.js.map                                   
npm notice 365B    fixup                                                    
npm notice 2.3kB   package.json                                             
npm notice 1.3kB   public/index.html                                        
npm notice 9.0kB   public/index.js                                          
npm notice 34.3kB  public/index.js.map                                      
npm notice 2.3kB   src/1byte.js                                             
npm notice 5.2kB   src/co2.js                                               
npm notice 70B     src/constants/file-size.js                               
npm notice 61B     src/constants/index.js                                   
npm notice 1.6kB   src/data/average-intensities-ember-2021.min.js           
npm notice 3.0kB   src/data/marginal-intensities-unfccc-2021.min.js         
npm notice 84B     src/helpers/index.js                                     
npm notice 1.4kB   src/hosting-api.js                                       
npm notice 1.7kB   src/hosting-json.node.js                                 
npm notice 2.3kB   src/hosting-node.js                                      
npm notice 232B    src/hosting.js                                           
npm notice 284B    src/index-node.js                                        
npm notice 354B    src/index.js                                             
npm notice 3.3kB   src/readme.md                                            
npm notice 10.5kB  src/sustainable-web-design.js                            
npm notice === Tarball Details === 
npm notice name:          @tgwf/co2                               
npm notice version:       0.11.0                                  
npm notice filename:      @tgwf/co2-0.11.0.tgz                    
npm notice package size:  5.6 MB                                  
npm notice unpacked size: 17.4 MB                                 
npm notice shasum:        9d9f0473146a170d0bf74091ab9b996ab609a166
npm notice integrity:     sha512-WewH5NJRI3OGB[...]7nnWPb+iNPjtQ==
npm notice total files:   115                                     
npm notice

Yeah, it was indeed the fixtures, but there are a few other culprits there:

npm notice 7.1kB   data/fixtures/countries.csv
npm notice 187.2kB data/fixtures/tgwf.har
npm notice 16.6MB  data/fixtures/url2green.test.db
npm notice 8.7kB   data/IFI_Default_Grid_Factors_2021_v3.1_unfccc.csv
npm notice 17.5kB  data/Lean-ICT-Materials-1byte-Model-2018.xlsx
npm notice 103.8kB data/Lean-ICT-Materials-Forecast-Model-2018.xlsx

This looks like it would indeed be an easy fix to change the .npmignore file slightly

@fershad
Copy link
Contributor

fershad commented Oct 7, 2022

@mrchrisadams I noticed you changed the .npmignore in d1717a7. However, when publishing the patch today the size is still huge. A small change to the .npmignore file should get us back down to ~500kb:

...
# Data
# exclude mode data
data/**

# but include the output js / json files
!data/output/**
# and include the minimized versions
!src/data/**
...

I also suggest we add the public folder to this.

I've created #117 to resolve this.

@fershad
Copy link
Contributor

fershad commented Oct 11, 2022

Merged in #117 and released in v0.11.2.

@fershad fershad closed this as completed Oct 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants