pub fn emit_commons_barrel(
name: &str,
groups: &BTreeMap<String, Vec<usize>>,
parsed: &[ParsedFile],
import_ext: ImportExt,
emitted: &mut HashSet<PathBuf>,
modules_out: &[StagedFile],
) -> Option<StagedFile>Expand description
v0.132: an aggregating barrel for a commons split across a directory.
Production emits a multi-file commons per file (out/<name>/*.ts) and never
an aggregate out/<name>.ts, but every test/integration import references the
commons as one namespace (import * as ns from "./<name>.js"). Emit
out/<name>.ts that export *s each of the commons’ source files so that
namespace import resolves for the directory layout exactly as it does for a
single file. The flat merge cannot collide: intra-commons symbol names are
already unique across every kind (bynk.resolve.duplicate_type/_fn/
_method), so no two files re-export the same name.
Returns None — no barrel — when the commons is not multi-file (a
single-file commons already owns out/<name>.ts; a barrel would collide), or
when this barrel path was already emitted (emitted dedups across the several
test/integration modules that may import the same commons).
groups maps each production unit name to the parsed indices of its files;
the multi-file predicate and the re-exported file set both read from there, so
the barrel can never drop a file that declares nothing type/fn/method-shaped
(which FileDeclIndex would omit).
#1820: a multi-file context‘s barrel is also part of a production bundle
build, emitted by run_checks ahead of the test passes, since its
composition root imports the context from out/<name>.ts too; on workers,
run_checks claims its path, since the context’s modules are the Worker’s.
run_checks alone passes modules_out, this unit’s staged modules, for
duplicated_export_reexports; the test passes, which only ever reach a
commons here, pass none. A commons’ files repeat no generated export: it
has no boundary codecs, and only a context rebrands a usesd type.