Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/deep-sails-peel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@solidjs/start": patch
---

Fixed shared chunk css not being server rendered in production (Vite 8 regression).
13 changes: 7 additions & 6 deletions apps/fixtures/css/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@ export default defineConfig({
* Creates a shared chunk with two components. Needed for the "SharedChunk" test!
* The vite manifest behaves differently for such shared chunks.
* More info: packages/start/src/config/lazy.ts
*
* TODO: When switching to Rolldown, migrate this to advancedChunks
* https://vite.dev/guide/rolldown.html#manualchunks-to-advancedchunks
*/
manualChunks(id) {
if (!id.includes("src/components/sharedChunk")) return;
return "shared";
codeSplitting: {
groups: [
{
name: "shared-css",
test: "src/components/sharedChunk",
},
],
},
},
},
Expand Down
8 changes: 6 additions & 2 deletions packages/start/src/config/lazy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,16 @@ const lazy = (): PluginOption => {
if (this.environment.name !== VITE_ENVIRONMENTS.client) return;

for (const chunk of Object.values(bundle)) {
if (chunk.type !== "chunk" || !chunk.isDynamicEntry || chunk.facadeModuleId) continue;
if (chunk.type !== "chunk" || chunk.facadeModuleId) continue;
Comment thread
birkskyum marked this conversation as resolved.
if (!chunk.viteMetadata?.importedCss.size) continue;

const moduleIds = chunk.moduleIds.filter(id => !id.endsWith("css"));
if (moduleIds.length <= 1) continue;

// Has to follow Vites implementation:
// https://github.com/vitejs/vite/blob/4be37a8389c67873880f826b01fe40137e1c29a7/packages/vite/src/node/plugins/manifest.ts#L179
const chunkName = `_${basename(chunk.fileName)}`;
for (const id of chunk.moduleIds) {
for (const id of moduleIds) {
sharedChunkNames[id] = chunkName;
}
}
Expand Down
Loading