-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Cleanup Svelte generator #18705
Cleanup Svelte generator #18705
Conversation
☁️ Nx Cloud ReportWe didn't find any information for the current pull request with the commit 50991a6. Check the Nx Cloud Github Integration documentation for more information. Sent with 💌 from NxCloud. |
@benmccann what's the best way to test these changes? We should probably sync up on how this fits in with all the changes we're making in 7.0 in For example, there's an architectural change since 6.4 that will allow a bunch of perf improvements and simplifications, but that is not currently compatible with addon-svelte-csf. I've created an issue here storybookjs/addon-svelte-csf#65. Until that's fixed and we have a good system for documenting the usage, I wouldn't be comfortable installing Svelte CSF by default. |
Ok, I've removed You can create a new Svelte project with:
You can create a new SvelteKit project with:
There will need to be additional changes for full SvelteKit support. |
Awesome @benmccann -- I'll try to kick the tires today! I'm so grateful to see all your improvements coming in. And with the 7.0 changes I think we'll be able to achieve a step change in DX for Vite-based projects .... 🚀 BTW, are you on our Discord? https://discord.gg/storybook Would love to chat when you have a min |
I pinged you on Discord. I have the same username there |
Just to understand, where are the duplication you are talking about ? Preprocessors are used here to generate documentation : https://github.com/storybookjs/storybook/blob/next/app/svelte/src/server/svelte-docgen-loader.ts#L55 If the preprocessors are not configured correctly, it will not works for typescript projects ? Or the svelte compiler is autodetecting itself the preprocessor to use ? |
The user has already specified the preprocessors to use in |
builder-vite use the same preprocessor options: https://github.com/storybookjs/builder-vite/blob/main/packages/builder-vite/svelte/csf-plugin.ts#L19 |
Yes, but those options are read directly from the config file so that the user doesn't have to specify them a second time: |
Maybe this logic should be implemented in the core storybook/app/svelte instead of the vite-builder ? This doesn't seem to be really related to vite. |
If each plugin has to load the Svelte config you're going to end up loading it more times. Here we load it once and then pass it to two plugins. So the way it's done now makes sense to me. But if the user were expected to create these plugins manually then I think it'd be better to encapsulate it inside the plugins so that the user is not responsible for loading the config file. |
What I was trying to say it's maybe the svelte.config.js should be loaded (once) by the storybook core svelte plugin and be available through svelteOptions like today. you don't have to change every plugins using it, and the logic will be shared by vite/webpack/whatever. I understand that letting the user configure preprocessor can be a source of errors. however, removing this option and hardcoding the location of "svelte.config.js" is a breaking change - probably an acceptable breaking change? - but I have projects I'm sure it will not work without change/fake svelte.config.js) |
I'm not sure I understand how that would work, but it's probably my lack of knowledge about the Storybook codebase. Does the Storybook Svelte plugin get invoked before the Vite/Webpack builder? How would it pass the options?
Yeah, I did not remove the option to avoid the breaking change, but instead made it optional with the defaults loaded from the config file. |
FWIW, I treated the change to start loading from the config file in the vite-builder as a breaking change, even though the config can be overridden from
Storybook has a way for presets to add/modify config settings and then access them elsewhere using
await presets.apply('svelteOptions') to access the config loaded from svelte.config.js . Is that what you had in mind, @j3rem1e?
|
Closing this in favor of #18799 |
What I did
main.cjs
. It's already set insvelte.config.js
. Setting it manually results in duplication and is often wrong causing breakages when it does not match the user's own config (e.g. TypeScript and Preprocessors support addon-svelte-csf#4)svelte-loader
should not be added indiscriminately. It is only needed for webpack projects, but Svelte projects use Vite by default, so it's mostly wrong to add it. Users will have set this up already if they're using Svelte and webpackHow to test
If your answer is yes to any of these, please make sure to include it in your PR.