Skip to content
This repository was archived by the owner on Apr 14, 2021. It is now read-only.

Proposal to .npmignore anything that's not needed for production #199

Closed
bensontrent opened this issue Jul 2, 2016 · 9 comments
Closed
Assignees

Comments

@bensontrent
Copy link

When using npm install with intl.js, I've found it requires 71 mb of disk space. Can this be trimmed down for production? I haven't researched the code yet, but it appears the json and jsonp folders are covered by complete.js? Or if json and jsonp are needed, is it possible to refactor duplicitous code? Could we lose the src and lib folders for npm installs? Could we direct npm to just the dist folder? I'd be happy to make a proposal through a pull request.

image

My sob story: I ran into a situation where I was using a corporate laptop that had a 128GB SSD hard drive; I had maybe 10 gb left at the beginning of the week, and then by Thursday the laptop crashed to the point a windows restore couldn't work as there wasn't space left. I had been installing many projects using npm install, and I discovered that typically 80% of the space in node modules was taken up by the Intl.js package.

For inspiration, I'm looking at the connect package. They obviously were saving every byte.
image

They use the "files" method in package.json to achieve this result when installing via npm.
image

Their source remains untouched in github with test and other files not needed during production

image

And considering the Intl.js's incredible popularity, economically, every byte counts.
image
Those numbers are kind of amazing.

@andyearnshaw
Copy link
Owner

Those numbers are amazing 😄.

Trimming down is tricky, as each of Intl.complete.js, json and jsonp offer an alternative option based on the polyfill consumer's preference. Intl.complete.js is commonly only used in Node or packaged apps that run locally, whereas json and jsonp are lightweight alternatives for browser environments.

We could possibly ditch either jsonp (~20M, whitespace/key quotes stripped) or json (~56M, human readable), depending on which is more popular to serve. @caridy, what do you think?

@caridy caridy self-assigned this Jul 5, 2016
@caridy
Copy link
Collaborator

caridy commented Jul 6, 2016

I will work on this on Thursday.

@caridy
Copy link
Collaborator

caridy commented Jul 21, 2016

ok, finally I get a chance to look at this problem holistically, here are my thoughts:

  • FT polyfill service relies on the npm pkg to build their own folder structure (they use dist/ and locale-data/jsonp)
  • People using browserify/webpack can choose individual locale data files (otherwise their bundle is unusable), and they do so from NPM :/, we can't really remove jsonp files from the pkg at this point.
  • I suspect that others might use locale-data/json, and removing it from the pkg will require a version bump (but I think it is worth it, those account for more than a half of the pkg)
  • I have revisited the docs, and the issues, and we've never talk about locale-data/json/, we might be fine.
  • we can trimming everything else.

I will submit a PR soon.

@caridy caridy mentioned this issue Jul 21, 2016
6 tasks
caridy added a commit that referenced this issue Sep 20, 2016
@caridy
Copy link
Collaborator

caridy commented Sep 20, 2016

@caridy
Copy link
Collaborator

caridy commented Sep 20, 2016

@bensontrent I did some partial clean up, but unfortunately we can't really remove dist/ because people are using it directly. I plan to do so in 1.3.x, in the meantime, I will keep this open.

@bensontrent
Copy link
Author

@caridy An 80% reduction in the npm package size? That's more than a modest partial cleanup, I'd say that's a win already. Here's what intl looks like after your revisions:

image

And here's a report by file type report:

image

Nice work!

@mgh
Copy link

mgh commented Sep 21, 2016

Glad to see the file size going down! But the json folder was removed in v1.2.5 -- for future reference, this should have probably been a major release, not a patch release, to avoid breaking the package for those of us that depended on it.

@caridy
Copy link
Collaborator

caridy commented Nov 17, 2016

ok, with 1.2.6 we are going down to ~500K package (~5mb expanded), which I think is sufficient for now.

@bensontrent thanks a lot for pushing us to get to that point.

@caridy caridy closed this as completed Nov 17, 2016
@bensontrent
Copy link
Author

Holy cow @caridy I'm impressed - a 93% savings. And look how popular Intl has become since we first started this conversation in July--the stats have doubled on what was already a very popular package.

My (certainly-inaccurate) napkin calculation estimates the 93% reduction in size saves 60 Terabytes of storage and transmission, every day.

image

Way to go! 😃

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants