storybook: [Bug]: Storybook builds twice on launch
Describe the bug
When starting Storybook (React latest + webpack 5 template) in a dev mode, build process runs twice before one can freely browse stories. After some debugging it turned out that the second build is triggered by the file system watcher because of ‘removal’ of storybook-config-entry.js and storybook-stories.js files. As I understood from the source code, these are only virtual modules that should not really exist as a separate physical files, so maybe they should be somehow excluded from the watch? I’m not quite sure how though 😅
This second build basically doubles Storybook launch time which for larger repos can be quite significant.
As a workaround, we created these files without any content but this is just a temporary solution.
Reproduction link
It happens on the clean sandbox reproduction repo
Reproduction steps
- Create clean reproduction repo with React latest + webpack 5 template (I assume that webpack part might be mandatory in order to reproduce the issue, while the React is optional and the same could happen with other libraries)
- Install packages and start storybook using standard commands
- After seeing ‘welcome box’ (with Storybook version, timings and URLs), notice that the progress plugin prints some output once again (on the clean reproduction repo it’s quite fast but as I mentioned before it is dependent on the size of the repo)
System
System:
OS: Windows 10 10.0.19045
CPU: (12) x64 Intel(R) Core(TM) i7-10750H CPU @ 2.60GHz
Binaries:
Node: 20.11.0 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.22 - C:\Program Files\nodejs\yarn.CMD <----- active
npm: 10.2.4 - C:\Program Files\nodejs\npm.CMD
pnpm: 9.1.2 - C:\Program Files\nodejs\pnpm.CMD
Browsers:
Edge: Chromium (125.0.2535.67)
npmPackages:
@storybook/addon-essentials: ^8.2.0-alpha.5 => 8.2.0-alpha.5
@storybook/addon-interactions: ^8.2.0-alpha.5 => 8.2.0-alpha.5
@storybook/addon-links: ^8.2.0-alpha.5 => 8.2.0-alpha.5
@storybook/addon-onboarding: ^8.2.0-alpha.5 => 8.2.0-alpha.5
@storybook/addon-webpack5-compiler-swc: ^1.0.3 => 1.0.3
@storybook/blocks: ^8.2.0-alpha.5 => 8.2.0-alpha.5
@storybook/react: ^8.2.0-alpha.5 => 8.2.0-alpha.5
@storybook/react-webpack5: ^8.2.0-alpha.5 => 8.2.0-alpha.5
@storybook/test: ^8.2.0-alpha.5 => 8.2.0-alpha.5
storybook: ^8.2.0-alpha.5 => 8.2.0-alpha.5
Additional context
No response
About this issue
- Original URL
- State: open
- Created 2 years ago
- Comments: 15 (10 by maintainers)
@pciarach OK I see what you mean. Does adding this to
main.jshelp with the problem for you?It feels like this is a bug in https://github.com/sysgears/webpack-virtual-modules - @ndelangen any ideas?
@pciarach Thanks for the context. This might be a known problem with no easy fix, but I’ll ask our local Webpack experts and we’ll see what we can figure out. @ndelangen @valentinpalkovic @tmeasday ?