Charlie Croom 3a33d5f54f
fix(storybook): improve speed of storybook plugin (#31277)
## 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
2025-05-22 08:22:01 -04:00
2019-03-07 13:23:11 -05:00

Nx - Smart Monorepos · Fast CI

CircleCI License NPM Version Semantic Release Commitizen friendly Join the chat at https://gitter.im/nrwl-nx/community Join the Official Nx Discord Server


Smart Monorepos · Fast CI

Build system, optimized for monorepos, with AI-powered architectural awareness and advanced CI capabilities.

Create a new Nx workspace with

npx create-nx-workspace

...or run

npx nx init

to add Nx to your existing workspace to get faster task scheduling, caching and more. More in the docs.

Learn about CI with Nx Cloud

Nx Cloud connects directly to your existing CI setup, helping you scale your monorepos on CI by leveraging remote caching, task distribution across multiple machines, automated e2e test splitting and automated task flakiness detection

Connect your existing Nx workspace with

npx nx connect

Learn more in the Nx CI docs »

Nx - Smart Monorepos · Fast CI

Want to help?

If you want to file a bug or submit a PR, read up on our guidelines for contributing and watch this video that will help you get started.

Nx - How to contribute video

Core Team

Victor Savkin Jason Jean Benjamin Cabanes Jack Hsu
Victor Savkin Jason Jean Benjamin Cabanes Jack Hsu
vsavkin FrozenPandaz bcabanes jaysoo
James Henry Jon Cammisuli Isaac Mann Juri Strumpflohner
James Henry Jon Cammisuli Isaac Mann Juri Strumpflohner
JamesHenry cammisuli isaacplmann juristr
Philip Fulcher Caleb Ukle Katerina Skroumpelou Colum Ferry
Philip Fulcher Caleb Ukle Katerina Skroumpelou Colum Ferry
philipjfulcher barbados-clemens mandarini Coly010
Emily Xiong Miroslav Jonaš Leosvel Pérez Espinosa Zachary DeRose
Emily Xiong Miroslav Jonaš Leosvel Pérez Espinosa Zachary DeRose
xiongemi meeroslav leosvelperez ZackDeRose
Craigory Coppola Chau Tran Nicholas Cunningham Max Kless
Craigory Coppola Chau Tran Nicholas Cunningham Max Kless
AgentEnder nartc ndcunningham MaxKless
Description
No description provided
Readme 619 MiB
Languages
TypeScript 95%
Rust 2.9%
JavaScript 1.3%
Kotlin 0.3%
MDX 0.3%
Other 0.1%