@marko/vite
Version:
A Marko plugin for Vite
35 lines (34 loc) • 1.75 kB
TypeScript
import serialize, { InjectType } from "./serializer";
type SerializedOrNull = null | ReturnType<typeof serialize>;
export interface DocManifest {
preload: string[];
"head-prepend": SerializedOrNull;
head: SerializedOrNull;
"body-prepend": SerializedOrNull;
body: SerializedOrNull;
}
export interface LinkAssetsDocManifest {
block: SerializedOrNull;
defer: SerializedOrNull;
}
export declare function generateDocManifest(basePath: string, rawHtml: string): Promise<DocManifest>;
/**
* Like `generateDocManifest`, but for the Marko compiler's built-in asset
* orchestration where assets are grouped by whether they should be render
* blocking instead of by document position. Only assets that could cause
* FOUC (or worse) when delayed are blocking — stylesheets and render
* blocking scripts are written inline with the html that uses them, while
* everything else (preloads, async/module scripts) can be injected after
* the fact (e.g. on a visibility trigger).
*
* In dev css is loaded through js modules, so nothing is safe to defer:
* passing `preventFOUC` (a unique id for the assets being flushed) puts all
* assets in the render blocking group and prepends parts that hide the page
* until the document's scripts have been imported. The id scopes the
* cleanup so independently flushed groups (the page and each lazily loaded
* template) unhide on their own schedule.
*/
export declare function generateLinkAssetsManifest(basePath: string, rawHtml: string, preventFOUC?: string): Promise<LinkAssetsDocManifest>;
export declare function getPreventFOUCParts(preload: string[], scopeId: string): (string | InjectType)[];
export declare function generateInputDoc(entry: string): string;
export {};