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
Auto imported component's style is loaded even if I don't use component #12801
Comments
/cc @antfu. I think issue is that styles are eagerly loaded for lazy imported components |
Is this only happens on dev? |
@antfu no, dev + (build + start) two problem |
Bring back by nuxt/framework#2227 |
bump |
/cc @antfu |
Also see #13778. |
@HochinChan Your situation is not related, I think. I would recommend not using global components for exactly these kind of performance reasons, but instead to rely on Nuxt to auto-import them where required. You can track #14584 for more prefetching improvements. |
Reproduction with latest Nuxt: https://stackblitz.com/edit/github-nd6mk4. |
https://stackblitz.com/edit/nuxt-starter-eyapnx When I access pages/index (without using any components), the styles of all the components and the styles of other pages are also loaded |
That should no longer be the case for pages on the edge channel, but yes, that was the purpose of my reproduction link - to show the issue. |
Sorry, I'm not quite sure what you mean, but I was wondering how to make it load only the style of the current page |
Use https://v3.nuxtjs.org/guide/going-further/edge-channel. See nuxt/framework#6662. It will still load component styles; that's what this issue is about. But it won't load page styles. |
I see, thanks. The other page styles won't load when I use @latest. |
We are working to make preload/prefetch smarter. Let's track the issue of global components in #14675. If there is any extra prefetch/preloading issue not caused by usage of global components please make another new issue with reproduction 🙏🏼 |
Environment
Reproduction
https://codesandbox.io/s/determined-sky-77qrl?file=/app.vue:19-43
Describe the bug
Nuxt 3 docs state "It will automatically import the components only if used".
Does components placed inside component dir is registered globally?
If the component is only get imported then why style is loaded even if the component is not used.
In this codesandbox: https://codesandbox.io/s/determined-sky-77qrl?file=/app.vue:19-43
I don't use the custom button component but still, the style from that component is loaded? 🤔
Additional context
No response
Logs
No response
The text was updated successfully, but these errors were encountered: