marko
Version:
Optimized runtime for Marko templates.
34 lines (33 loc) • 1.46 kB
TypeScript
import { types as t } from "@marko/compiler";
declare module "@marko/compiler/dist/types" {
interface ProgramExtra {
registeredExports?: Map<string, ReservedExport>;
}
}
/** The canonical name a reserved register id is exported under, and its id. */
export interface ReservedExport {
registerId: string;
exportName: string;
}
/** A reserved export, plus the template that declares it. */
export interface ResolvedExport extends ReservedExport {
filename: string;
}
declare const _default: {
analyze(this: unknown, fn: t.NodePath<t.Function>): void;
};
export default _default;
export declare function finalizeFunctionRegistry(): void;
/**
* Tracks a function imported from another template that reserved a register id.
* The importing template registers it (under the reserved id) when its own
* references reach something serialized.
*/
export declare function trackImportedFn(importDecl: t.NodePath<t.ImportDeclaration>, local: string, resolved: ResolvedExport): void;
/**
* Finds the id reserved for an export, following `export ... from` hops. Each
* template only records the exports it declares, so this resolves on demand:
* a template in an import cycle is read while it is still analyzing, and would
* hand out an incomplete map if the ids were pushed ahead of time.
*/
export declare function resolveRegisteredExport(file: t.BabelFile, exportName: string, seen?: Set<string>): ResolvedExport | undefined;