Skip to content
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

Builder-Vite: Fix Turbosnap #30522

Merged
merged 1 commit into from
Feb 12, 2025
Merged

Builder-Vite: Fix Turbosnap #30522

merged 1 commit into from
Feb 12, 2025

Conversation

valentinpalkovic
Copy link
Contributor

@valentinpalkovic valentinpalkovic commented Feb 12, 2025

Closes #30521

What I did

Re-added the slash after virtual: for some virtual ids to not break Chromatic's Turbosnap

Checklist for Contributors

Testing

The changes in this PR are covered in the following automated tests:

  • stories
  • unit tests
  • integration tests
  • end-to-end tests

Manual testing

This section is mandatory for all contributions. If you believe no manual test is necessary, please state so explicitly. Thanks!

Documentation

  • Add or update documentation reflecting your changes
  • If you are deprecating/removing a feature, make sure to update
    MIGRATION.MD

Checklist for Maintainers

  • When this PR is ready for testing, make sure to add ci:normal, ci:merged or ci:daily GH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found in code/lib/cli-storybook/src/sandbox-templates.ts

  • Make sure this PR contains one of the labels below:

    Available labels
    • bug: Internal changes that fixes incorrect behavior.
    • maintenance: User-facing maintenance tasks.
    • dependencies: Upgrading (sometimes downgrading) dependencies.
    • build: Internal-facing build tooling & test updates. Will not show up in release changelog.
    • cleanup: Minor cleanup style change. Will not show up in release changelog.
    • documentation: Documentation only changes. Will not show up in release changelog.
    • feature request: Introducing a new feature.
    • BREAKING CHANGE: Changes that break compatibility in some way with current major version.
    • other: Changes that don't fit in the above categories.

🦋 Canary release

This PR does not have a canary release associated. You can request a canary release of this pull request by mentioning the @storybookjs/core team here.

core team members can create a canary release here or locally with gh workflow run --repo storybookjs/storybook canary-release-pr.yml --field pr=<PR_NUMBER>

name before after diff z %
createSize 0 B 0 B 0 B - -
generateSize 80.5 MB 80.5 MB 0 B 0.68 0%
initSize 80.5 MB 80.5 MB 0 B -0.3 0%
diffSize 97 B 97 B 0 B -0.33 0%
buildSize 7.24 MB 7.27 MB 26 kB 2.75 0.4%
buildSbAddonsSize 1.87 MB 1.89 MB 17.1 kB 15.75 0.9%
buildSbCommonSize 195 kB 195 kB 0 B - 0%
buildSbManagerSize 1.88 MB 1.88 MB 204 B -0.76 0%
buildSbPreviewSize 0 B 0 B 0 B - -
buildStaticSize 0 B 0 B 0 B - -
buildPrebuildSize 3.94 MB 3.96 MB 17.3 kB 6.18 0.4%
buildPreviewSize 3.3 MB 3.31 MB 8.71 kB 1.28 0.3%
testBuildSize 0 B 0 B 0 B - -
testBuildSbAddonsSize 0 B 0 B 0 B - -
testBuildSbCommonSize 0 B 0 B 0 B - -
testBuildSbManagerSize 0 B 0 B 0 B - -
testBuildSbPreviewSize 0 B 0 B 0 B - -
testBuildStaticSize 0 B 0 B 0 B - -
testBuildPrebuildSize 0 B 0 B 0 B - -
testBuildPreviewSize 0 B 0 B 0 B - -
name before after diff z %
createTime 14.3s 25s 10.6s 0.51 42.5%
generateTime 20.8s 22.9s 2s 3.42 🔺9%
initTime 4.9s 5s 69ms -0.16 1.4%
buildTime 9.9s 11.8s 1.9s 3.16 🔺16.6%
testBuildTime 0ms 0ms 0ms - -
devPreviewResponsive 5.4s 5s -430ms -0.77 -8.6%
devManagerResponsive 4.3s 3.9s -356ms -0.34 -9%
devManagerHeaderVisible 1s 976ms -98ms 1.49 🔰-10%
devManagerIndexVisible 1.1s 998ms -158ms 1.31 🔰-15.8%
devStoryVisibleUncached 2.9s 2.7s -204ms -1.32 🔰-7.3%
devStoryVisible 1.1s 1s -130ms 1.37 🔰-12.3%
devAutodocsVisible 868ms 772ms -96ms 0.13 -12.4%
devMDXVisible 831ms 885ms 54ms 1.52 🔺6.1%
buildManagerHeaderVisible 796ms 784ms -12ms -0.32 -1.5%
buildManagerIndexVisible 895ms 902ms 7ms -0.3 0.8%
buildStoryVisible 710ms 721ms 11ms -0.31 1.5%
buildAutodocsVisible 720ms 623ms -97ms -0.26 -15.6%
buildMDXVisible 575ms 637ms 62ms -0.17 9.7%

Greptile Summary

Based on the provided files and context, I'll provide a concise summary of the changes:

Fixed TurboSnap functionality in the Vite builder by modifying virtual module path handling in development mode.

  • Modified virtual path prefix in code/builders/builder-vite/src/transform-iframe-html.ts to include forward slash
  • Updated script source path in code/builders/builder-vite/input/iframe.html for proper virtual module resolution
  • Standardized virtual file paths in code/builders/builder-vite/src/virtual-file-names.ts with consistent forward slash usage
  • Fixed issue where TurboSnap failed to detect CSF globs when no changes were present

The changes are focused on path resolution for virtual modules to ensure proper functionality of TurboSnap in the Vite builder.

@valentinpalkovic valentinpalkovic self-assigned this Feb 12, 2025
@valentinpalkovic valentinpalkovic marked this pull request as ready for review February 12, 2025 12:46
@valentinpalkovic valentinpalkovic added the patch:yes Bugfix & documentation PR that need to be picked to main branch label Feb 12, 2025
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

3 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings | Greptile

Copy link

nx-cloud bot commented Feb 12, 2025

View your CI Pipeline Execution ↗ for commit 473e1b9.

Command Status Duration Result
nx affected -t check -c production --parallel=7 ✅ Succeeded 12s View ↗
nx run-many -t build -c production --parallel=3 ✅ Succeeded 3s View ↗

☁️ Nx Cloud last updated this comment at 2025-02-12 13:13:18 UTC

Copy link
Contributor

@JReinhold JReinhold left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like the proper fix would have been to keep the slash out, but add it in the preview-stats plugin instead. But I'm fine with this due to time.

@valentinpalkovic
Copy link
Contributor Author

valentinpalkovic commented Feb 12, 2025

Logic in preview-stats would be more complex to only apply the forward slash to these four virtual files. I don't know which side-effect it would have if we always append the forward slash to all virtual: ids. That's the reason I have decided for this way.

@valentinpalkovic valentinpalkovic merged commit a019db8 into next Feb 12, 2025
74 of 82 checks passed
@valentinpalkovic valentinpalkovic deleted the valentin/fix-turbosnap branch February 12, 2025 14:31
@valentinpalkovic valentinpalkovic changed the title Builder-Vite: Fix turbosnap Builder-Vite: Fix Turbosnap Feb 12, 2025
valentinpalkovic added a commit that referenced this pull request Feb 12, 2025
Builder-Vite: Fix turbosnap
(cherry picked from commit a019db8)
@github-actions github-actions bot added the patch:done Patch/release PRs already cherry-picked to main/release branch label Feb 12, 2025
@codykaup
Copy link

@valentinpalkovic @JReinhold is the goal to remove that slash? If so, we can add that as an entrypoint for TurboSnap: chromaui/chromatic-cli#1155

@valentinpalkovic
Copy link
Contributor Author

Thanks @codykaup. That definitely helps! I will keep the code though for backwards compatibility

@codykaup
Copy link

Thanks @codykaup. That definitely helps! I will keep the code though for backwards compatibility

Should I go ahead with that change or are we good with keeping the slash?

@valentinpalkovic
Copy link
Contributor Author

valentinpalkovic commented Feb 12, 2025

Looking forward it would be good to get rid of the slash so please go ahead with your PR. In the future, Storybook will also remove the leading / before virtual:. So please add a new entry point with removing the slash immediately before and after virtual: and then the PR is good to go

codykaup added a commit to chromaui/chromatic-cli that referenced this pull request Feb 12, 2025
codykaup added a commit to chromaui/chromatic-cli that referenced this pull request Feb 12, 2025
codykaup added a commit to chromaui/chromatic-cli that referenced this pull request Feb 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug builder-vite ci:normal patch:done Patch/release PRs already cherry-picked to main/release branch patch:yes Bugfix & documentation PR that need to be picked to main branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: TurboSnap Error after updating @storybook/react-vite to 8.5.4
3 participants