-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Include styles for dynamically imported components #5138
Conversation
🦋 Changeset detectedLatest commit: 036e35c The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
It might be nice to see if we can use Vite's |
maybe related: injecting a link for component styles is pending this: sveltejs/vite-plugin-svelte#341 If we want to avoid the js, is there a way to compile only the css for a component? |
Can we merge this as is so that styles of dynamic imported components load at least in production builds without javascript? |
Not sure I understand what that is and what benefit it brings?
Not without changes to Svelte itself
We generally try and avoid that — it ends up being more work as you need to create a new issue and then (eventually) a new PR. Better to just fix it in one go, even if it means a slight delay |
Alright, I think this is ready to go |
#5137. This is a partial fix — it solves the SSR problem in prod builds, and solves it in dev when the page is reloaded (because
node.ssrTransformResult
has been computed by that point), but not for the initial page load. Not yet sure what the solution looks like. Maybe we can wait untilload
has completed before computing the styles. (The most obvious alternative is to eagerly load the dynamically imported modules, but that would be a bad idea in the case where they're dynamically imported precisely because they can't be loaded on the server.)Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
Tests
pnpm test
and lint the project withpnpm lint
andpnpm check
Changesets
pnpm changeset
and following the prompts. All changesets should bepatch
until SvelteKit 1.0