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

Vite: Include node_modules in stats file #30711

Open
wants to merge 2 commits into
base: next
Choose a base branch
from

Conversation

JReinhold
Copy link
Contributor

@JReinhold JReinhold commented Feb 27, 2025

As requested by @jmhobbs

What I did

Changed the filter so node_modules are also included in the preview-stats.json output on build, similar to how it is in Webpack today. This allows TurboSnap to be more granular on a per-package level instead of just bailing whenever a single package dependency has changed.

I did a comparison of the changes for our own internal Storybook:

Without node_modules With node_modules
Lines 5.779 20.488
Size 177 KB 630 KB

Checklist for Contributors

Testing

The changes in this PR are covered in the following automated tests:

  • stories
  • unit tests
  • integration tests
  • end-to-end tests

Manual testing

This section is mandatory for all contributions. If you believe no manual test is necessary, please state so explicitly. Thanks!

Documentation

  • Add or update documentation reflecting your changes
  • If you are deprecating/removing a feature, make sure to update
    MIGRATION.MD

Checklist for Maintainers

  • When this PR is ready for testing, make sure to add ci:normal, ci:merged or ci:daily GH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found in code/lib/cli-storybook/src/sandbox-templates.ts

  • Make sure this PR contains one of the labels below:

    Available labels
    • bug: Internal changes that fixes incorrect behavior.
    • maintenance: User-facing maintenance tasks.
    • dependencies: Upgrading (sometimes downgrading) dependencies.
    • build: Internal-facing build tooling & test updates. Will not show up in release changelog.
    • cleanup: Minor cleanup style change. Will not show up in release changelog.
    • documentation: Documentation only changes. Will not show up in release changelog.
    • feature request: Introducing a new feature.
    • BREAKING CHANGE: Changes that break compatibility in some way with current major version.
    • other: Changes that don't fit in the above categories.

🦋 Canary release

This pull request has been released as version 0.0.0-pr-30711-sha-c594b56f. Try it out in a new sandbox by running npx [email protected] sandbox or in an existing project with npx [email protected] upgrade.

More information
Published version 0.0.0-pr-30711-sha-c594b56f
Triggered by @JReinhold
Repository storybookjs/storybook
Branch jeppe/include-node-modules-in-stats-json
Commit c594b56f
Datetime Thu Feb 27 21:31:49 UTC 2025 (1740691909)
Workflow run 13576270859

To request a new release of this pull request, mention the @storybookjs/core team.

core team members can create a new canary release here or locally with gh workflow run --repo storybookjs/storybook canary-release-pr.yml --field pr=30711

name before after diff z %
createSize 0 B 0 B 0 B - -
generateSize 79.7 MB 79.7 MB 106 B 0.44 0%
initSize 79.7 MB 79.7 MB 106 B 0.44 0%
diffSize 97 B 97 B 0 B - 0%
buildSize 7.31 MB 7.31 MB 0 B 0.49 0%
buildSbAddonsSize 1.9 MB 1.9 MB 0 B 0.44 0%
buildSbCommonSize 195 kB 195 kB 0 B - 0%
buildSbManagerSize 1.89 MB 1.89 MB 0 B 0.02 0%
buildSbPreviewSize 0 B 0 B 0 B - -
buildStaticSize 0 B 0 B 0 B - -
buildPrebuildSize 3.98 MB 3.98 MB 0 B 0.71 0%
buildPreviewSize 3.33 MB 3.33 MB 0 B 0.32 0%
testBuildSize 0 B 0 B 0 B - -
testBuildSbAddonsSize 0 B 0 B 0 B - -
testBuildSbCommonSize 0 B 0 B 0 B - -
testBuildSbManagerSize 0 B 0 B 0 B - -
testBuildSbPreviewSize 0 B 0 B 0 B - -
testBuildStaticSize 0 B 0 B 0 B - -
testBuildPrebuildSize 0 B 0 B 0 B - -
testBuildPreviewSize 0 B 0 B 0 B - -
name before after diff z %
createTime 19.8s 26.7s 6.8s 1.36 🔺25.8%
generateTime 18.7s 20.9s 2.2s 0.4 10.7%
initTime 4.3s 5.3s 988ms 1.08 18.6%
buildTime 8.2s 8.7s 559ms -0.78 6.4%
testBuildTime 0ms 0ms 0ms - -
devPreviewResponsive 5.3s 4.9s -461ms -0.92 -9.4%
devManagerResponsive 5.1s 4.6s -516ms -0.97 -11%
devManagerHeaderVisible 781ms 723ms -58ms -0.78 -8%
devManagerIndexVisible 791ms 757ms -34ms -0.75 -4.5%
devStoryVisibleUncached 1.7s 2s 282ms 0.48 14%
devStoryVisible 810ms 759ms -51ms -1.08 -6.7%
devAutodocsVisible 842ms 686ms -156ms -0.85 -22.7%
devMDXVisible 703ms 785ms 82ms 0.04 10.4%
buildManagerHeaderVisible 665ms 645ms -20ms -0.85 -3.1%
buildManagerIndexVisible 727ms 660ms -67ms -0.98 -10.2%
buildStoryVisible 649ms 630ms -19ms -0.74 -3%
buildAutodocsVisible 581ms 603ms 22ms -0.35 3.6%
buildMDXVisible 547ms 557ms 10ms -0.47 1.8%

Greptile Summary

This PR modifies the Vite builder to include node_modules dependencies in the stats file output, enabling more granular tracking of dependencies for TurboSnap.

  • Modified code/builders/builder-vite/src/plugins/webpack-stats-plugin.ts to remove the filter that excluded node_modules from the stats output
  • The change increases stats file size (~177KB to ~630KB) but provides better granularity for incremental builds
  • Allows TurboSnap to track changes at the package level rather than requiring full rebuilds when any dependency changes

@JReinhold JReinhold changed the title include node_modules in stats file in Vite Vite: include node_modules in stats file Feb 27, 2025
Copy link

nx-cloud bot commented Feb 27, 2025

View your CI Pipeline Execution ↗ for commit 6453a71.

Command Status Duration Result
nx run-many -t build --parallel=3 ✅ Succeeded 1m 57s View ↗

☁️ Nx Cloud last updated this comment at 2025-02-28 20:43:29 UTC

@JReinhold JReinhold self-assigned this Feb 27, 2025
@JReinhold JReinhold changed the title Vite: include node_modules in stats file Vite: Include node_modules in stats file Feb 28, 2025
Copy link

@jmhobbs jmhobbs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works great in my tests, thank you!

@JReinhold JReinhold marked this pull request as ready for review February 28, 2025 20:24
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

1 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings | Greptile

@storybook-pr-benchmarking
Copy link

Package Benchmarks

Commit: 6453a71, ran on 28 February 2025 at 20:46:51 UTC

The following packages have significant changes to their size or dependencies:

@storybook/svelte-vite

Before After Difference
Dependency count 131 131 0
Self size 23 KB 23 KB 0 B
Dependency size 36.43 MB 36.55 MB 🚨 +124 KB 🚨
Bundle Size Analyzer Link Link

@storybook/sveltekit

Before After Difference
Dependency count 139 139 0
Self size 48 KB 48 KB 0 B
Dependency size 39.74 MB 39.86 MB 🚨 +124 KB 🚨
Bundle Size Analyzer Link Link

@storybook/vue3-vite

Before After Difference
Dependency count 104 104 0
Self size 17 KB 17 KB 0 B
Dependency size 42.61 MB 42.73 MB 🚨 +124 KB 🚨
Bundle Size Analyzer Link Link

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

Successfully merging this pull request may close these issues.

3 participants