Files
deepseek-harness/packages/client/modules/tests
imccyu 28dfa06cca feat(client): load package-local chunk dependencies (#9286)
* feat(client): load package-local chunk dependencies

Chunks of one dynamic Client package may now require each other
synchronously. A registration's deps names the chunks its factory
requires, and the module system registers them before the factory runs;
require.async takes a { deps } prefetch hint so a chunk group downloads
in one round. The dynamic preset writes both lists and moves the chunks
an entry requires into its client.js, shifting the entry source map.

Refs #9275

* fix(client): accept entry-carried chunks in the publication closure check

The dynamic Client build moves the chunks an entry requires into the
entry file and deletes their own files, so a require of such a chunk
names no published file. publint-all now accepts a ./client.<name>.js
request when a script in the same directory registers the package entry
and that chunk, using the shared chunk file-name rule.

Refs #9275

* fix(client): restart entry chunk arrival and keep entry-carried dynamic imports

- arrive() restarts from the entry script when the owner is invalidated
  while the entry's registration deps download, as importChunk already
  does for lazy chunks.
- A dynamic import of a chunk the entry file carries keeps Rolldown's
  synchronous require: the chunk has no file left to download. A chunk
  that imports the package entry dynamically now fails the build like a
  static import.
- The WebWorker packer reuses CLIENT_CHUNK_FILE from client-modules
  instead of its own pattern; the rule is bundled into the packer build.

Refs #9275

* refactor(client): order chunk arrival methods after importChunk

Place arriveChunk directly after importChunk so the download code it took
over from importChunk stays aligned with master, followed by arriveChunks
and requireChunk. No logic or comment changes.

Refs #9275

* fix(client): limit the entry-carried chunk exemption to factory requires

publint-all accepted any relative request for a chunk that the entry file
registers, including an ESM import that Node resolves itself. The
exemption now covers only a synchronous require inside the factory of a
__ModuleLoader__.load registration; every other relative request still
needs its published file.

Refs #9275

* fix(client): let a prefetch hint only start chunk downloads

With a hint, the hinted chunks shared the requested chunk's visited set,
so a failed dependency reached the caller without the registration chain.
Each hinted chunk now arrives with its own visited set and an ignored
failure; the requested chunk waits only for its registration deps and
wraps their failures, so a hinted chunk that no registration requires
cannot fail the request.

Refs #9275

* fix(client): wait for prefetch hint arrivals before a chunk request ends

A chunk request discarded its hinted arrivals, so after an owner
invalidation it could retry and register the new generation while a
hinted download of the dropped generation was still pending; that
download then deleted the new records. The request now waits for every
hinted arrival it started, on success, failure, and before a retry,
while still ignoring their failures.

Refs #9275
2026-11-26 15:21:49 +08:00
..