Skip to main content

emit_worker_handlers_barrel

Function emit_worker_handlers_barrel 

Source
pub fn emit_worker_handlers_barrel(
    name: &str,
    indices: &[usize],
    parsed: &[ParsedFile],
    emitted: &[StagedFile],
    import_ext: ImportExt,
    layout: &WorkerLayout,
) -> StagedFile
Expand description

#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.

Each file also emits its own copy of what its declarations need from outside it (a boundary type’s codecs, a usesd commons type’s rebrand), so two files can both export one name; the barrel re-exports each such name from one module of emitted, this unit’s (duplicated_export_reexports).