Skip to content

fix(storybook): improve speed of storybook plugin #31277

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
merged 1 commit into from
May 22, 2025

Conversation

comp615
Copy link
Contributor

@comp615 comp615 commented May 19, 2025

Current Behavior

#22953 updated the way that storybook parsing works to always do full TS tree resolution instead of AST parsing. While this is more accurate, it's orders of magnitude slower...creating a bottleneck in graph creation for larger repos which use the plugin.

The only reason we need to do this complex functionality is to determine if we use angular or not.

Expected Behavior

Graph creation should be quite fast.

This PR returns the old behavior, and uses the new behavior as an additive fallback. In most cases this will result in extremely fast parsing when the framework is defined inline, and in the failure case, it will result in unnoticeably slower parsing as the incremental difference is minor.

Before:

Time for '@nx/storybook/plugin:createNodes' 13536.203667

After:

Time for '@nx/storybook/plugin:createNodes' 292.584667

An alternative solve (at least in our case) would be to add an option to skip angular detection...essentially letting people bypass the whole reason for doing this config parsing. Although that's probably not a sustainable option.

NOTE: A majority of the remaining slowness in this plugin is spent hashing the files for the target cache. If we wanted to, we could further speed this up by making some assumptions there...but that may drastically harm repos which rely on the fully resolution behavior

Related Issue(s)

Fixes #31276

Copy link

vercel bot commented May 19, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Updated (UTC)
nx-dev ⬜️ Ignored (Inspect) Visit Preview May 22, 2025 8:55am

@comp615 comp615 force-pushed the ccroom/storybook_speed branch 2 times, most recently from d9e4b51 to 591d358 Compare May 19, 2025 21:19
@comp615 comp615 marked this pull request as ready for review May 19, 2025 21:23
@comp615 comp615 requested a review from a team as a code owner May 19, 2025 21:23
@comp615 comp615 requested a review from mandarini May 19, 2025 21:23
@comp615
Copy link
Contributor Author

comp615 commented May 19, 2025

fyi @leosvelperez

Copy link
Contributor

nx-cloud bot commented May 22, 2025

View your CI Pipeline Execution ↗ for commit 0403ab6.

Command Status Duration Result
nx affected --targets=lint,test,build,e2e,e2e-c... ✅ Succeeded 37m 34s View ↗
nx run-many -t check-imports check-commit check... ✅ Succeeded 18s View ↗
nx-cloud record -- nx-cloud conformance:check ✅ Succeeded 2s View ↗
nx-cloud record -- nx format:check ✅ Succeeded 3s View ↗
nx-cloud record -- nx sync:check ✅ Succeeded 2s View ↗
nx documentation ✅ Succeeded 1m 14s View ↗

☁️ Nx Cloud last updated this comment at 2025-05-22 09:39:22 UTC

Bring back old, innacurate, but fast, implementation of getting the
storybook framework. Use it preferentially, and fall back to the
new one if it fails.
@leosvelperez leosvelperez force-pushed the ccroom/storybook_speed branch from 591d358 to 0403ab6 Compare May 22, 2025 08:52
Copy link
Member

@leosvelperez leosvelperez left a comment

Choose a reason for hiding this comment

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

Thanks @comp615! Good catch! This makes total sense.

@jaysoo jaysoo merged commit 3a33d5f into nrwl:master May 22, 2025
6 checks passed
Copy link

This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 28, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Graph Creation: @nx/storybook/plugin:createNodes is very slow in large projects
3 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy