Skip to content

Commit 36428cb

Browse files
ryansolidbrenelzcursoragent
committed
normalize emitted lazy entries in the raw output bundle
Downstream plugins inspecting the client bundle in generateBundle (and Vite's manifest plugin serializing it) saw lazy facade chunks marked isEntry, mistaking them for application entries. Apply the existing reclassification to the Rollup bundle itself, ahead of the client asset map build. Ports the fix from #266. Co-authored-by: Brenley Dueck <brenleydueck@gmail.com> Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent d358e57 commit 36428cb

3 files changed

Lines changed: 24 additions & 1 deletion

File tree

.changeset/clean-lazy-entries.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'vite-plugin-solid': patch
3+
---
4+
5+
Reclassify emitted lazy facade chunks as dynamic entries in the raw output bundle so downstream plugins do not mistake them for application entries.

examples/css-matrix/test/run.mjs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,17 @@ async function runMode(mode) {
292292
sharedChunks.size === 1,
293293
`expected 1 shared chunk, saw ${sharedChunks.size} (${[...sharedChunks].join(', ')})`,
294294
);
295+
// Emitted lazy facade chunks must be reclassified as dynamic entries in
296+
// the output bundle itself — downstream plugins (and this manifest,
297+
// which Vite generates from the bundle) must see exactly one real entry.
298+
const entries = Object.keys(manifest).filter((k) => manifest[k].isEntry);
299+
record(
300+
mode,
301+
'ssr',
302+
'single application entry in client manifest',
303+
entries.length === 1 && entries[0] === 'src/entry-client.tsx',
304+
`entries: ${entries.join(', ')}`,
305+
);
295306
}
296307

297308
// ---- Phase 2: browser ------------------------------------------------

src/index.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,9 @@ function normalizeSourceMap(map: string | babel.TransformOptions['inputSourceMap
240240
* though they are semantically dynamic entries. Reclassify any entry that is
241241
* dynamically imported by another chunk so the runtime's entry-asset
242242
* detection (which keys off `isEntry`) can't pick a lazy facade instead of
243-
* the real client entry.
243+
* the real client entry. Works on both the Vite manifest.json shape and the
244+
* raw Rollup output bundle — both key entries by name and expose
245+
* `dynamicImports` / `isEntry` with the same meaning.
244246
*/
245247
function normalizeEmittedLazyEntries(manifest: Record<string, any>) {
246248
const dynamicKeys = new Set<string>();
@@ -585,6 +587,11 @@ export default function solidPlugin(options: Partial<Options> = {}): Plugin {
585587

586588
generateBundle(_options, bundle) {
587589
if (!isBuild || !isClientBuild(this)) return;
590+
// Reclassify emitted lazy facade chunks in the raw bundle (not just the
591+
// serialized manifest read back later) so downstream plugins inspecting
592+
// the bundle don't mistake them for application entries. Must precede
593+
// the client asset map build, which keys off dynamic entries.
594+
if (options.ssr) normalizeEmittedLazyEntries(bundle);
588595
substituteClientManifest(bundle, buildClientAssetMap(bundle, projectRoot, base));
589596
},
590597

0 commit comments

Comments
 (0)