@@ -312,6 +312,10 @@ export default function solidPlugin(options: Partial<Options> = {}): Plugin[] {
312312 // Driven from moduleParsed so it covers every lazy() target, including
313313 // import.meta.glob entries that never pass through the moduleUrl transform.
314314 const emittedLazyChunks = new Set < string > ( ) ;
315+ // Keep the emitted references because a lazy module's importer may be
316+ // removed from the final bundle, leaving no dynamic-import edge to identify
317+ // its facade chunk during generateBundle.
318+ const emittedLazyChunkRefs : string [ ] = [ ] ;
315319
316320 // Whether the current hook invocation belongs to a client (browser) build.
317321 // Builder-mode builds (e.g. SolidStart's nitro plugin) run the client and
@@ -559,7 +563,9 @@ export default function solidPlugin(options: Partial<Options> = {}): Plugin[] {
559563 if ( ! / \. [ m c ] ? [ t j ] s x ? $ / i. test ( cleanId ) ) continue ;
560564 if ( emittedLazyChunks . has ( depId ) ) continue ;
561565 emittedLazyChunks . add ( depId ) ;
562- this . emitFile ( { type : 'chunk' , id : depId , preserveSignature : 'exports-only' } ) ;
566+ emittedLazyChunkRefs . push (
567+ this . emitFile ( { type : 'chunk' , id : depId , preserveSignature : 'exports-only' } ) ,
568+ ) ;
563569 }
564570 } ,
565571
@@ -625,7 +631,22 @@ export default function solidPlugin(options: Partial<Options> = {}): Plugin[] {
625631 // serialized manifest read back later) so downstream plugins inspecting
626632 // the bundle don't mistake them for application entries. Must precede
627633 // the client asset map build, which keys off dynamic entries.
628- if ( options . ssr ) normalizeEmittedLazyEntries ( bundle ) ;
634+ if ( options . ssr ) {
635+ for ( const ref of emittedLazyChunkRefs ) {
636+ let fileName : string ;
637+ try {
638+ fileName = this . getFileName ( ref ) ;
639+ } catch {
640+ // Ignore references retained from a previous watch build.
641+ continue ;
642+ }
643+ const chunk = bundle [ fileName ] ;
644+ if ( ! chunk || chunk . type !== 'chunk' ) continue ;
645+ chunk . isEntry = false ;
646+ chunk . isDynamicEntry = true ;
647+ }
648+ normalizeEmittedLazyEntries ( bundle ) ;
649+ }
629650 substituteClientManifest ( bundle , buildClientAssetMap ( bundle , projectRoot , base ) ) ;
630651 } ,
631652
0 commit comments