Przeglądaj źródła

fix(client): consume bootstrap handoff queue

imccyu 1 miesiąc temu
rodzic
commit
4ad6e28663

+ 1 - 1
packages/client/modules/src/client/system.ts

@@ -88,7 +88,7 @@ export class ClientModuleSystem implements ClientModuleLoader {
     // Replace first: a bundle that executes while queued handoffs are draining
     // must register against the live sink rather than append behind the drain.
     win.__ModuleLoader__ = sink
-    for (const handoff of queued?.handoffs ?? []) sink.load(handoff)
+    for (const handoff of queued?.handoffs.splice(0) ?? []) sink.load(handoff)
   }
 
   /** Register one bundle factory, rejecting a script that executes twice without invalidation. */

+ 1 - 0
packages/client/modules/tests/loader.client.spec.ts

@@ -72,6 +72,7 @@ describe('lazy CJS arrival', () => {
     const b = bench([row('runtime')])
     const exports = await b.loader.import('runtime', '', {})
     expect((exports as { marker: string }).marker).toBe('preloaded')
+    expect(handoffs).toEqual([])
     expect(b.fetched).toEqual([])
     expect(win.__ModuleLoader__?.mode).toBe('live')
   })