rolldown-lazy-missing-factory-repro

Minimal Rolldown-only reproduction for a lazy dev runtime MissingFactoryError

0
0
0
JavaScript
public

Rolldown lazy compilation can omit an unregistered shared factory

Minimal Rolldown-only reproduction for a MissingFactoryError in lazy dev
mode. It uses the experimental dev-engine and runtime APIs directly; Vite and a
browser are not involved.

Reproduction

pnpm install
pnpm repro

pnpm repro is expected to exit with code 1 and currently throws:

MissingFactoryError: No factory registered for module shared.js

Module graph

main.js
├── import('./lazy-a.js') ──┐
└── import('./lazy-b.js') ──┴── shared.js

Both lazy entries statically import the same shared.js module.

What the harness models

  1. Rolldown compiles the first lazy entry.
  2. The serving layer reports that its HTTP response completed by calling
    notifyPayloadDelivered(first.filename).
  3. The harness intentionally does not execute the first payload. This models a
    response that reached the browser but failed before module evaluation, so its
    factories were never registered in DevRuntime.
  4. Rolldown compiles the second lazy entry for the same client.
  5. The second payload calls initModule('shared.js'), but it does not include a
    factory for shared.js because the per-client shipped state attributes that
    factory to the first payload.

This distinction matters because notifyPayloadDelivered() acknowledges
transport delivery, not successful JavaScript evaluation.

Expected behavior

The second lazy payload must not depend on a factory that has never been
registered in the client runtime. It should either include the shared factory
or use a protocol that confirms successful runtime registration before omitting
it from later payloads.

Tested version

The lockfile pins the pkg.pr.new package for Rolldown commit
224f40bd081f80b108026c07315ae741ac3baa84, which contains the fix from
rolldown#10772.

v0.3.3[beta]