Skip to content

Speed up npm ci ~55% by creating separate package.json for storybook stories #10612

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

Merged

Conversation

cdrini
Copy link
Collaborator

@cdrini cdrini commented Mar 22, 2025

Refactor. I found npm ci has been super slow to get through, and often hanging when running in our testing deploys. I tried removing tesseract/some other dependencies, but it seemed to make little difference. It turned out that storybook was taking a decent chunk of time when npm installing, so tried splitting it out into a separate package.json , and npm ci became quite a bit faster! I set the npm commands to auto-install the new package.json though, so there should be no breaking changes in anyone's flow. The npm run storybook command will work as before.

Only potentially breaking change is that when storybook is built, it'll build in stories/storybook-static instead of the root-level storybook-static/.

Technical

Some metrics of fresh installs:

Before, with storybook:

time npm ci --no-audit took 7m12s, 6m12, avg 6m42
node_modules is 474 MB
npm list | wc -l is 58

After, without storybook:

npm rm storybook @storybook/addon-essentials @storybook/cli @storybook/html-webpack5

time npm ci --no-audit took 3m45s, 2m21, avg 3m03 (55% reduced)
node_modules is 300 MB (36% reduced)
npm list | wc -l is 53

Testing

Screenshot

Up and running!

image

Stakeholders

@jimchamp

@cdrini cdrini added Type: Refactor/Clean-up Issues related to reorganization/clean-up of data or code (e.g. for maintainability). [managed] Theme: Development Issues related to the developer experience and the dev environment. [managed] labels Mar 22, 2025
@codecov-commenter
Copy link

codecov-commenter commented Mar 22, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 17.22%. Comparing base (2e231fa) to head (814ed0e).
Report is 141 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #10612      +/-   ##
==========================================
- Coverage   17.27%   17.22%   -0.05%     
==========================================
  Files          87       88       +1     
  Lines        4845     4859      +14     
  Branches      860      862       +2     
==========================================
  Hits          837      837              
- Misses       3477     3489      +12     
- Partials      531      533       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

cdrini added 3 commits March 22, 2025 19:29
I found storybook was taking a decent junk of time when npm installing,
so split it out into a separate package.json . I set the npm commands to
auto-install the new package.json though, so there should be no breaking
changes in anyone's flow. The `npm run storybook` will work as before.

Only potentialy breaking change is that when storybook is built, it'll
build in stories/storybook-static instead of the root-level
storybook-static/.
Since these dependencies are only ever used for local development, they
are incredibly unlikely to need the rigor associated with
package-lock.json, which is usually more important for production-facing
code.
@cdrini cdrini force-pushed the refactor/storybook-package-json branch from 43dfb8b to 814ed0e Compare March 22, 2025 23:29
@cdrini cdrini marked this pull request as ready for review March 22, 2025 23:31
@cdrini cdrini changed the title Speed up npm ci 48% by creating separate package.json for storybook stories Speed up npm ci ~55% by creating separate package.json for storybook stories Mar 22, 2025
@github-actions github-actions bot added the Needs: Response Issues which require feedback from lead label Mar 23, 2025
@mekarpeles mekarpeles removed the Needs: Response Issues which require feedback from lead label Mar 24, 2025
@mekarpeles mekarpeles merged commit c8a681a into internetarchive:master Mar 24, 2025
5 checks passed
@mekarpeles mekarpeles self-assigned this Mar 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Theme: Development Issues related to the developer experience and the dev environment. [managed] Type: Refactor/Clean-up Issues related to reorganization/clean-up of data or code (e.g. for maintainability). [managed]
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants