Expand description
The runtime as per-module files (ADR 0615, #2426).
A project emits __bynk_runtime/<module>.{ts,js} for the runtime modules its
emitted code reaches, and no others. Generated code imports each helper from
the module that defines it; this module is where a list of runtime names
becomes one import per defining module, and where the reached set is closed
over the modules’ own imports.
The directory name starts with _, which a Bynk identifier cannot (#1653),
and a user file mirrors its source path, so no user path can collide with it.
Constants§
- RUNTIME_
DIR - The directory (at the root of the output) the runtime modules are emitted to.
Functions§
- closure_
files - The files for
reached(module, extension) pairs closed over the runtime modules’ own imports. Type-only edges count:tscover the emitted.tsneeds the files, and one rule keeps the output deterministic. - emit_
all_ runtime_ modules - Every runtime module as
(path, source), for tests that stage a runtime by hand beside emitted code. Extensionjsspells sibling imports as.js. - reached_
in - Every runtime module an emitted file’s imports name, found in the
specifiers it imports and in the
import … fromlines of its verbatim text. - rewrite_
runtime_ imports - Rewrite the
import … from "<…>/runtime.js"statements of hand-written TypeScript (adapter bindings, first-party or the user’s) to per-module imports. Multi-line, unterminated, indented and trailing-comment forms are handled. A statement that is not a braced named import of runtime exports (a namespace import, a typo’d name) is left as written, fortscto report. - runtime_
export_ names - Every name a runtime module exports. The import-shadow test reads it to find a runtime name a module spells in text its tree cannot see.
- runtime_
import_ stmts split_runtime_importas top-level statements, for producers building aTsProgram.