Skip to main content

Module commons_barrel

Module commons_barrel 

Source
Expand description

The commons barrel: an aggregating out/<name>.ts for a multi-file commons or context.

Production output (#1820): a multi-file context’s barrel is part of a production bundle build, so it lives here and not in testgen. Moved out of the test-harness generator unchanged (1B.2a, #4028).

Functions§

duplicated_export_reexports
#1820: the explicit re-exports a multi-file context’s barrel needs where two or more of its files’ modules export one name. User names are unique across a unit, but each file emits its own copy of what its declarations need from outside it: the context’s rebrand of a usesd commons type, that commons type’s codecs re-exported, a boundary type’s codecs (wherever the type is declared). Each copy is a function of the type alone, so the barrel re-exports the name from the first module (sorted by path) that exports it, which takes precedence over export *; without it, export * is ambiguous (TS2308) and drops the name at runtime. merged names the helpers the barrel defines itself (merged_unit_helpers), which are skipped.
emit_commons_barrel
v0.132: an aggregating barrel for a commons split across a directory.
emit_worker_handlers_barrel
#1820: handlers.ts for a context split across files, on Workers. It re-exports each file’s module, so the Worker’s entry point, its composition root and every consuming context see the context as one module, as they do a single-file context’s handlers.ts. Like a multi-file unit’s test barrel (emit_commons_barrel), it also defines the merged helpers each file generates for itself (merged_unit_helpers), which export * alone would leave ambiguous: only __resetAgents, since a Worker’s files export no surface.
merged_unit_helpers
#1844 review: the barrel’s own definitions of the helpers every file of a multi-file context generates for itself. User names are unique across a unit, but these are not: each file with agents exports __resetAgents (over its own agents), and each file with services exports __makeSurface and the context’s __<Ctx>Deps (over its own services). Two files of either kind made the barrel’s export * ambiguous (TS2308), and at runtime the ambiguous name is dropped from the namespace, so a test’s __resetAgents() was undefined. Where two or more files contribute one, the barrel exports a merged definition, which takes precedence over the star exports: reset every file’s agents; combine every file’s surface over the intersection of their deps.