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
v3.20.0 breaks Vite Storybook builds #4916
Comments
You can help we by guiding me how and where the build process is configured that produces these outputs. My guess so far is that it is related to the changed asset naming logic if several emitted files share their contents. Previously, Rollup would use the name of the file that is emitted first. Now, it uses sorting to pick a name.
to see if this also has the issue? If yes, then it is definitely the asset handling logic and we need to revisit that. |
I think I have an idea what might be going on. The change broke |
I think you are right. Vite calls |
Fix at #4919 |
This issue has been resolved via #4919 as part of rollup@3.20.1. You can test it via |
Rollup Version
3.20.0
Operating System (or Browser)
Mac/Linux
Node Version (if applicable)
No response
Link To Reproduction
https://634ff621f2a0d0f01971eae7-oclscgzyyl.chromatic.com/?path=/story/example-button--primary
Expected Behaviour
The daily storybook CI jobs, which create new projects with all the latest dependencies, began to fail yesterday. Specifically, vite projects were failing, mostly svelte and vue3, though it was a bit inconsistent. At first we thought this was due to the 4.2.1 release of Vite, but nothing in that small release could cause our issue. We pinned vite to an older version, and kept getting the failures
Then we looked at rollup, which also had a release yesterday. We pinned rollup to 3.19.1, and the failures stopped.
This is a really tricky one to troubleshoot, because so far it only reproduces reliably in CI, not locally. Though it can happen occasionally locally as well, it's not reliable enough for troubleshooting (once in 10 or 20 tries maybe).
Here is the storybook build output from a rollup 3.19.1 build:
https://app.circleci.com/pipelines/github/storybookjs/storybook/44977/workflows/b7df949a-2c35-4003-bccf-adba5b6cf938/jobs/502484/parallel-runs/22/steps/22-104
And here's the resulting storybook:
https://634ff621f2a0d0f01971eae7-pwrriypbvy.chromatic.com/?path=/story/example-button--primary
Actual Behaviour
In Storybook, we create a list of dynamic imports for stories: https://github.com/storybookjs/storybook/blob/351dbb6bac38be546c9653a2a538277fde9ff882/code/lib/builder-vite/src/codegen-importfn-script.ts#L29-L37. Vite (or rollup?) takes that dynamic import and creates a subarray of files (chunks) for each import. In rare cases, a chunk is included in that array which does not exist (e.g.
Button-bc1a867b.css
). Here's an example.and we get an error like:
This is an example storybook containing this error: https://634ff621f2a0d0f01971eae7-oclscgzyyl.chromatic.com/?path=/story/example-button--primary
To see the import array, look in the non-sourcemapped version of
virtual:/@storybook/builder-vite/storybook-stories.js
. Compare it to the working version from rollup 3.19.1 above, and you will see that in the working version, there is a reference toindex-bc1a867b.css
, which was generated in both cases.Here is the build log of that storybook, which shows that no
Button-X.css
was created, butindex-X.css
was: https://app.circleci.com/pipelines/github/storybookjs/storybook/44964/workflows/ea841823-ce14-4065-a2be-38cc65a33364/jobs/502424/parallel-runs/22/steps/22-104I wish I could give you a simpler, more minimal reproduction, but as I said I'm having a hell of a time getting this to happen locally, there's some kind of race condition involved. Perhaps it happens more reliably in CI due to the limited number of CPU cores available there, but I don't know how to artificially limit them when running locally. If you have any suggestions for us, that would be great.
Please let me know if there's anything we can do to try to help troubleshoot. As it is, we will need to tell Vite Storybook users to pin to rollup 3.19.1 until this is resolved.
The text was updated successfully, but these errors were encountered: