-
-
Notifications
You must be signed in to change notification settings - Fork 99
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
Warning with :global(*)
in a component with no html elements
#153
Comments
You're right that it's a bug in I don't think it can be dynamically added depending on on the markup though, maybe we would have to suppress that warning by default then. |
it's complicated. This extra The case of a "component with styles but without a template" wasn't considered when this was implemented. And i'm curious why you would use that. If there is nothing to scope to, you're better off using external css files, right? To ignore this warning by default, we could add a filter to |
Besides "global styles without a template", I actually hit this issue a while ago for one of our Svelte components that contains only subcomponents (no HTML elements). So this issue could happen in the wild unintentionally too. EDIT: Actually my scenario is kinda a code smell too as it would also happen when the style tag has |
This warning is specifically only emitted when there is not a single element in the template where a scope can be applied. So i'd say the warning is a sign for code-smell in 99% of cases it happens. So instead of filtering it we could issue a seaprate code + message so that the user learns about the potential issue and for legitimate usecases they can decide to ignore it via custom onwarn |
Describe the bug
If I have a component like this
it gives this warning when running the dev server and going to
localhost:3000
I think this is a bug here due to the fact that it doesn't show up in the svelte repl, or vs code, although I could be wrong, if so sorry about that.
Reproduction
You can clone this repo https://github.com/Zachiah/vite-plugin-svelte-warning-with-global-selector and just run the dev server and go to localhost:3000
Logs
System Info
Severity
annoyance
The text was updated successfully, but these errors were encountered: