Svelte: Fix conflicting variable names and support for +page.svelte files#30369
Svelte: Fix conflicting variable names and support for +page.svelte files#30369JReinhold merged 4 commits intostorybookjs:nextfrom
+page.svelte files#30369Conversation
There was a problem hiding this comment.
2 file(s) reviewed, 5 comment(s)
Edit PR Review Bot Settings | Greptile
|
I wanted to write tests for this case, but given that the changes were applied to And also a quick question. Should I make three separate errors inside |
|
View your CI Pipeline Execution ↗ for commit e0154a5.
☁️ Nx Cloud last updated this comment at |
Package BenchmarksCommit: No significant changes detected, all good. 👏 |
+page.svelte files
|
Oh, I completely screwed up git while trying to push a fix to this branch, accidentally merging it. 🙃 If it works I'll just leave as is, otherwise I'll revert it.
You can just create a Vitest test file in
I think the raw errors you have here are fine, given that this should be unreachable. Users shouldn't reach these cases even if they do something wrong (right?), so it's more a sanity check than an actual guide for users. |
|
CI is passing and I've manually checked that it fixes the two issues. Great work. 💪 |
Closes #29636
Closes #30212
What I did
I've replaced the previous implementation of getting the component name - which was copied from Svelte internals. It doesn't cover edge cases.
Now, it access the AST of compiled output of Svelte file. I believe this is a final source of truth to avoid naming collision with other identifiers. This function handles legacy and modern version of Svelte.
Checklist for Contributors
Testing
The changes in this PR are covered in the following automated tests:
Manual testing
+page.sveltecomponentssvelte-vitesandboxsrccreate a+page.sveltefile and fill it with whatever text you want+page.stories.tsfile with:Conflicting variables
svelte-vitesandboxGreeting.sveltefile with (the trick here is that there is a variable name with the same as the file name):Greeting.stories.tsfile with:Documentation
MIGRATION.MD
Checklist for Maintainers
When this PR is ready for testing, make sure to add
ci:normal,ci:mergedorci:dailyGH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found incode/lib/cli-storybook/src/sandbox-templates.tsMake 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/coreteam 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>Greptile Summary
This PR updates the component name extraction logic in the Svelte docgen plugin to handle both Svelte 4 and 5 compatibility by using compiled AST output.
getComponentNamefunction incode/frameworks/svelte-vite/src/plugins/svelte-docgen.tsto extract names from compiled ASTIS_SVELTE_V4flag incode/frameworks/svelte-vite/src/utils.tsto handle version-specific logic+page.svelte)💡 (4/5) You can add custom instructions or style guidelines for the bot here!