chore: Chromatic turbosnap#10125
Open
snowystinger wants to merge 12 commits into
Open
Conversation
|
Build successful! 🎉 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
First, I upgraded chromatic to the latest CLI version.
After that, I attempted to turn on turbo snap, only to find out that there was a file artifact necessary for it to work, it's included in webpack and there's a community vite version, but there is no parcel version. So I set out to have Claude write me a Parcel Reporter Plugin to generate
preview-stats.json.This is
preview-stats.jsonwhich contains a json map that tells chromatic what files a story depends on, so that if one of those files changes, it retakes the snapshots for that story file. It looks a little like this:So if I make a change to TagGroup, then Chromatic TurboSnap knows to run Forms and TagGroup.
And farther back, if I make a change to RAC TagGroup, then it's also a change to S2 TagGroup, which again results in the same stories. We have no RAC Chromatic and v3 doesn't use RAC, so that's why we only see the S2 ones.
There are a few handy methods to debug issues with this.
After running a
yarn build:chromaticyou can run thisTo see every story file that a particular file will affect.
You can also run the entire Chromatic command with a
--dry-runby appending that flag to our script target. Also, there are various options for--trace-changedand we may want to turn that off entirely when our changes affect many files.After running this end to end, I see in my console something like this (I changed the background color of Tag's in S2).

Which I promptly denied here https://www.chromatic.com/build?appId=5f0dd5ad2b5fc10022a2e320&number=1227 You can also see the number of snapshots used in the top right of the report. For instance, the first one has 20 snapshots, 1228 also has the same 20 after reverting my change and all of them pass against the baseline, then finally 1229: https://www.chromatic.com/build?appId=5f0dd5ad2b5fc10022a2e320&number=1229 has zero snapshots because there were no changes that would affect a story.
Resources :
https://github.com/storybookjs/storybook/blob/next/code/builders/builder-vite/src/plugins/webpack-stats-plugin.ts
https://www.youtube.com/watch?v=TZKIlqLF_Xk
📝 Test Instructions: