storybook: Docs slowing down reloading
Reloading changes made to a component is super slow.
The build process hangs on 70% - sealing React Docgen Typescript Plugin for 2-3 seconds. Then, tons of react-syntax-highlighter entries are output in the list of built files.
I’m using react-boilerplate-cra-template with storybook added via npx sb init.
I’m not using the docs addon at all.
I’ve changed main.js to:
const resolve = require('path').resolve;
module.exports = {
stories: ['../src/**/*.stories.mdx', '../src/**/*.stories.@(js|jsx|ts|tsx)'],
addons: [
'@storybook/addon-links',
'@storybook/preset-create-react-app',
{
name: '@storybook/addon-essentials',
options: {
docs: false,
},
},
]
};
The react-syntax-highlighter files no longer pop up in the list of built files, but the process is still quite slow and it hangs
on 70% - sealing React Docgen Typescript Plugin
Environment Info:
System:
OS: Linux 5.4 Ubuntu 20.04.1 LTS (Focal Fossa)
CPU: (24) x64 AMD Ryzen 9 3900X 12-Core Processor
Binaries:
Node: 12.18.3 - ~/.nvm/versions/node/v12.18.3/bin/node
Yarn: 1.22.5 - /usr/bin/yarn
npm: 6.14.6 - ~/.nvm/versions/node/v12.18.3/bin/npm
Browsers:
Chrome: 85.0.4183.102
Firefox: 80.0.1
npmPackages:
@storybook/addon-actions: ^6.0.21 => 6.0.21
@storybook/addon-essentials: ^6.0.21 => 6.0.21
@storybook/addon-links: ^6.0.21 => 6.0.21
@storybook/node-logger: ^6.0.21 => 6.0.21
@storybook/preset-create-react-app: ^3.1.4 => 3.1.4
@storybook/react: ^6.0.21 => 6.0.21
About this issue
- Original URL
- State: open
- Created 4 years ago
- Reactions: 27
- Comments: 39 (14 by maintainers)
Commits related to this issue
- Storybook quick-fix Source: https://github.com/storybookjs/storybook/issues/12585 — committed to digitalungdom-se/digitalungdom.se by Nautman 4 years ago
- Speed up storybook builds (From ~10s to ~2.5s). I noticed the build was hanging for a long time on "70% - sealing React Docgen Typescript Plugin" so I did some googling and found https://github.com/s... — committed to act-now-coalition/covid-act-now-website by mikelehen 3 years ago
- Speed up storybook builds (From ~10s to ~2.5s). (#3829) I noticed the build was hanging for a long time on "70% - sealing React Docgen Typescript Plugin" so I did some googling and found https://gi... — committed to act-now-coalition/covid-act-now-website by deleted user 3 years ago
@latviancoder what happens when you configure the following setting in
.storybook/main.js:I have the same problem (the build hangs for about 5 seconds at this stage:
"70% sealing plugins DocGenPlugin")With the
typescript: {reactDocgen: 'react-docgen'}option enabled, rebuilding is very fast, but almost all types are missing from the document.With the option enabled:
Without:
The main reason that
react-docgenvsreact-docgen-typescriptis slower is how each library get the type information.react-docgen: uses babel + plugin-typescript to parse the each file 1 by 1. Since babel is per file it’s inherently faster. A side effect of this is that since it’s not parsing every file to gain the full type information more complex types aren’t handled correctly, or at least some information will be missingreact-docgen-typescript: uses the typescript parser to parse each one of you files. This library will load all of the files from your tsconfig into 1 project/program and use that to get as much of the type definition that it can. While this provides potentially more accurate type information is is inherently slow. It’s not just one file it’s looking at it’s the entire compilation. This could be anywhere from a few files to thousands of files leading to the longer build and reload timesI’ve done some optimizations to make
react-docgen-typescriptquicker:These optimization resulted in
react-docgen-typescriptbeing much quicker in storybook project. To further optimize the only thing I can think of is a cache stored intmpthat stores docgen information between storybook startups. So if no files changes storybook should start quicker than the last time. I’ll look into shuffling some code around in the plugin to see if we can gain any speed there.If anyone has other ideas on how to optimize the behavior of
react-docgen-typescript-pluginI like to merge pull requests ;PThis helped me too, thanks!
Only the project sources are included.
I see no difference in performance when switching
reactDocgenon/off.Hello!
I had a similar issue. Rebuilding was taking more than 20 seconds and most of the time seemed to be spent on the docgen plugin.
I tried to migrate to 6.1 but it didn’t change anything.
However, I tried your following advice:
@shilman:
And it worked like a charm 👏 🎉 Thank you! Now our rebuild time is around 1 second.