Vite: Fix svelte docgen and svelte-native stories #19339
Merged
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.
Issue: #19217
Typescript-based svelte components did not generate docs correctly, and svelte-native stories were not possible.
What I did
In the transition to 7.0, we neglected to load svelte options from
svelte.config.js
(andsvelteOptions
from storybook overrides) and pass them to the svelte docgen plugin, which means that svelte components written with typescript did not work correctly.Also, while we brought over the
csfPlugin
for svelte, we never actually used it. So, svelte-native stories would be broken even if@storybook/addon-svelte-csf
was added. The fix here is a bit of a temporary one, hopefully. It uses the same strategy from the 6.5 vite-builder, but it would be better if we could add vite-support to the addon directly, which I've suggested in storybookjs/addon-svelte-csf#64 (comment).How to test
Currently we do not have a svelte-vite typescript sandbox, nor do we have any svelte-native stories. But, I bootstrapped my own project, and copied over the
dist
folder from thesvelte-vite
framework in this branch, and confirmed that both docgen and svelte-native stories do not work without these changes, and do work with them.