You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
This is a continuation of #14252. In NebulaCMS, I'm conditionally loading the actual editor form (https://github.com/Snugug/nebula-cms/blob/main/src/client/Admin.svelte#L233-L238) from a client:load component. In development, all of the CSS appears to load fine, but in production, the CSS for MetadataForm doesn't load and there's no errors in the console.
If helpful, I tried tracing this with an LLM, and the LLM suggests that this is the flow that's the problem:
@sveltejs/vite-plugin-svelte sets cssScopeTo metadata on Svelte CSS virtual
In the SSR build, Rollup tree-shakes conditionally-rendered components (behind {#if} blocks that don't execute during prerendering). Vite's CSS tree-shaking uses cssScopeTo to also remove their CSS from the SSR output
But Astro's cssModuleToChunkIdMap still maps all CSS module IDs from the SSR chunk (they're present as modules, just content-empty)
In the client build, allCssInSSR evaluates to true (all IDs mapped), so cssBuildPlugin deletes the client CSS asset from the bundle
Result: only SSR-rendered component styles make it to the final output
The LLM's suggested fix (internal t my project) is to override cssscopeTo via Vite plugin, which does appear to work, so it looks like it is at least related to that.
What's the expected result?
Svelte components that are rendered from NPM models, even if they're conditionally included in the code, should have their CSS available in a production build
Astro Info
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
This is a continuation of #14252. In NebulaCMS, I'm conditionally loading the actual editor form (https://github.com/Snugug/nebula-cms/blob/main/src/client/Admin.svelte#L233-L238) from a
client:loadcomponent. In development, all of the CSS appears to load fine, but in production, the CSS for MetadataForm doesn't load and there's no errors in the console.If helpful, I tried tracing this with an LLM, and the LLM suggests that this is the flow that's the problem:
@sveltejs/vite-plugin-sveltesetscssScopeTometadata on Svelte CSS virtual{#if}blocks that don't execute during prerendering). Vite's CSS tree-shaking usescssScopeToto also remove their CSS from the SSR outputcssModuleToChunkIdMapstill maps all CSS module IDs from the SSR chunk (they're present as modules, just content-empty)allCssInSSRevaluates to true (all IDs mapped), socssBuildPlugindeletes the client CSS asset from the bundlecssScopeTofix from PR Include styles for conditionally rendered Svelte 5 components #15227 adds the deleted CSS filename topagesToCss, butinlineStylesheetsPluginiteratesObject.entries(bundle)— the asset was already deleted, so it's never processedThe LLM's suggested fix (internal t my project) is to override
cssscopeTovia Vite plugin, which does appear to work, so it looks like it is at least related to that.What's the expected result?
Svelte components that are rendered from NPM models, even if they're conditionally included in the code, should have their CSS available in a production build
Link to Minimal Reproducible Example
https://github.com/Snugug/nebula-cms/releases/tag/v0.1.5
Participation