-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
fix: remove svelte-options
from svelte-vite
#20942
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with removing the svelteOptions
but I'm not so sure about not adding vite-plugin-svelte
. We have this pattern for all our Vite-based frameworks, and I can think of a few scenarios where it will still be needed:
- Users building UI libraries without any app, but just a Storybook and a custom build configuration. They won't have a
vite.config
file, and thus we need to add the minimal here. - Users with custom Vite config paths that we don't automatically detect, so there won't be a default Vite config to extend from.
Maybe @IanVS has some background knowledge here, since this is seen in most of the Vite-frameworks.
That's not really possible. Even if you're building a library and not an app, you still need a
That would cause a world of pain. We'll be missing the SvelteKit plugins and all of the user's configuration. It's better that we address that rather than cover it up. Perhaps if we don't see a |
There is now a builder option to specify the path to a custom vite config. It's a good idea to add a warning message with instructions, I'll look into that. I think for sveltekit specifically, it makes sense to remove the requirement for the plugin since as @benmccann said, it's guaranteed that the user has it if they're using sveltekit. We can also re-evaluate if we hear use cases from users who don't have it somehow. |
@IanVS but this change in on the |
Oh sorry, I was on my phone and assumed it was sveltekit since it was from @benmccann and he was talking about sveltekit.
That's not true in all cases. We do indeed find a good number of folks building, for example, react components without any vite config, which is handled by the consuming apps. Our very own @joshwooding maintains a library like this. I suppose the same thing can be done in svelte projects. I guess this is a downside to extending sveltekit from svelte-vite. I wonder if we're better off duplicating some code and decoupling the two. |
Ah, so we can have Svelte libraries that don't do any bundling and in that case you should still be able to run Storybook. Does Storybook always need a bundler? It looks like it adds |
Right, Storybook does always need a bundler. So it's possible that someone would run
It's still possible to use svelte with webpack, right? I do wonder if we could make a way to invert the default for svelte though, and default to vite and only use webpack if we detect a webpack config. That might be tricky based on the way the CLI works, I'd have to look.
We don't actually create a file, but we do create a vite config, that we provide to the vite server when it starts up or when we build for production.
It sounds like your suggestion is that instead of adding the plugin if the plugin isn't found, to add it if a vite config is not found. I think I like that, since it addresses the case we're trying to handle, though I need to think about how we can accomplish it. |
For now, what do you think about leaving it the way it was, and updating this PR to just remove |
svelte-options
from svelte-vite
Yeah, agreed. I sent #20966 regarding the default for new project creation |
So, just to confirm what this is doing. We previously kept the option around so that users could override their app's svelte config for Storybook. We were loading their |
I'm honestly fine with either, but I think whatever we do, our arguments are not specific to Svelte, so it should be done across all the Vite frameworks for consistency.
I'll refer to my investigation I did in #20236, specifically:
The |
Agree 💯 |
|
||
// Add svelte plugin if not present | ||
// Add svelte plugin if the user does not have a Vite config of their own |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment isn't exactly accurate for right now, though it hopefully will be sometime in the future, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You said above:
We don't actually create a file, but we do create a vite config, that we provide to the vite server when it starts up or when we build for production.
I was assuming that this in-memory Vite config would be created whether or not a vite.config.js
is present. I suppose the old comment might be a bit more accurate in that it applies either way whether or not that file is present. But I think my comment better describes the use case we're trying to address and when we might encounter it, which is perhaps more useful for folks who are editing this code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I was being pedantic. They could have a vite config without the plugin, and we would add it. I'm just splitting hairs.
What I did
Removed two unnecessary pieces of functionality. We don't need to add
vite-plugin-svelte
as it will always be present of the user's app won't work. We also don't need to addsvelteOptions
as I believe this was just a holdover from before we loaded thesvelte.config.js
fileChecklist
MIGRATION.MD
Maintainers
make sure to add the
ci:merged
orci:daily
GH label to it.["cleanup", "BREAKING CHANGE", "feature request", "bug", "documentation", "maintenance", "dependencies", "other"]