emitImports() function
Emit the import statements for the runtimes a file uses.
Signature:
export declare function emitImports(names: readonly RuntimeName[], map?: ImportMap): string;
Parameters
|
Parameter |
Type |
Description |
|---|---|---|
|
names |
readonly RuntimeName[] |
The runtimes this file takes symbols from. |
|
map |
(Optional) Redirections, from parseImportMap(). |
Returns:
string
The import statements, newline-terminated, or '' for none.
Remarks
Statements are **merged by resolved specifier**. Redirecting several runtimes at one package is the whole point of the option, and emitting one import per original specifier would then produce three imports of the same module in a file — which is a lint error, and reads as an oversight rather than as the redirection it is. Specifiers and symbols are both sorted, so the output is stable and a regenerated file diffs cleanly.
Example
emitImports(['rpc', 'zod'], { zod: '@my-org/runtime',
'@imqueue/rpc': '@my-org/runtime' });
// "import { classType, property, z } from '@my-org/runtime';\n"
Read this page as plain markdown — no HTML, no navigation. For pasting into an LLM, or for an agent to fetch.