Skip to main content

Module runtime_files

Module runtime_files 

Source
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: tsc over the emitted .ts needs 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. Extension js spells 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 … from lines 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, for tsc to 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_import as top-level statements, for producers building a TsProgram.