marko
Version:
Optimized runtime for Marko templates.
36 lines (35 loc) • 1.33 kB
TypeScript
import { types as t } from "@marko/compiler";
declare module "@marko/compiler/dist/types" {
interface ProgramExtra {
needsCompat?: boolean;
isInteractive?: boolean;
hasClientStatement?: boolean;
page?: boolean;
}
}
interface EntryState {
init: boolean;
load: boolean;
/** Depth of enclosing templates whose modules the bundle already loads:
* below a root everything arrives through its imports, and a lazy subtree
* is loaded by its own load entry. */
bundled: number;
roots: string[];
/** Assets of templates the bundle never loads; the entry imports them. */
assets: Set<string>;
/** Assets that arrive through a bundled template's imports; the entry
* imports them itself only when it links nothing (a server only page). */
bundledAssets: Set<string>;
/** Whether each reached file was only ever seen below a bundled template. */
visited: Map<string, boolean>;
}
type EntryFile = t.BabelFile & {
[kState]?: EntryState;
};
type VisitChild = (id: string, bundled?: boolean) => void;
declare const kState: unique symbol;
declare const builder: {
build(entryFile: EntryFile, exportInit?: boolean): t.Statement[];
visit(file: t.BabelFile, entryFile: EntryFile, visitChild?: VisitChild): void;
};
export default builder;