Skip to content

Commit 7f4c411

Browse files
committed
fix: skip entry imports in non-entry findAssetsInViteManifest
1 parent 5ed5efc commit 7f4c411

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

packages/start/src/server/manifest/prod-ssr-manifest.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ function createHtmlTagsForAssets(assets: string[]) {
6666
}));
6767
}
6868

69+
const entryId = import.meta.env.START_CLIENT_ENTRY.slice(2);
70+
let entryImports: string[] | undefined = undefined;
71+
6972
function findAssetsInViteManifest(
7073
manifest: any,
7174
id: string,
@@ -85,17 +88,30 @@ function findAssetsInViteManifest(
8588
return [];
8689
}
8790

91+
if (!entryImports) {
92+
entryImports = [
93+
entryId,
94+
...(manifest[entryId]?.imports ?? [])
95+
];
96+
}
97+
98+
// Only include entry imports, if we are specifically crawling the entry
99+
// Chunks (e.g. routes) that import something from entry, should not render entry css redundantly
100+
const excludeEntryImports = id !== entryId;
101+
88102
const assets = [
89103
...(chunk.assets?.filter(Boolean) || []),
90104
...(chunk.css?.filter(Boolean) || []),
91105
];
92106
if (chunk.imports) {
93107
stack.push(id);
94108
for (let i = 0, l = chunk.imports.length; i < l; i++) {
109+
const importId = chunk.imports[i];
110+
if (!importId || (excludeEntryImports && entryImports.includes(importId))) continue;
95111
assets.push(
96112
...findAssetsInViteManifest(
97113
manifest,
98-
chunk.imports[i],
114+
importId,
99115
assetMap,
100116
stack,
101117
),

0 commit comments

Comments
 (0)