vite-plugin-shopify-theme-islands
Version:
Vite plugin for island architecture in Shopify themes
45 lines (44 loc) • 1.83 kB
TypeScript
import { type ReviveOptions } from "./contract.js";
import type { ResolveTagFn } from "./options.js";
export interface ResolvedCustomDirective {
name: string;
entrypoint: string;
}
export interface ReviveCompileInputs {
root: string;
directories: string[];
directoryFiles: Set<string>;
islandFiles: Set<string>;
tagSource?: "registeredTag" | "filename";
resolveTag?: ResolveTagFn;
customDirectives?: Array<{
name: string;
entrypoint: string;
}>;
reviveOptions: ReviveOptions;
}
export interface RevivePlan {
runtimePath: string;
directoryGlobs: string[];
islandPaths: string[] | null;
resolvedTags: Record<string, string | false> | null;
customDirectives: ResolvedCustomDirective[] | null;
reviveOptions: ReviveOptions;
/** Maps absoluteFilePath → effective tag. Populated only in registeredTag mode. */
ownershipMap: ReadonlyMap<string, string | false>;
}
export interface ReviveCompilerPorts {
toLoadPaths(islandFiles: Set<string>, root: string): string[];
readFile?(path: string): string | null;
}
export interface ReviveCompileResolvePorts {
resolveEntrypoint(entrypoint: string): Promise<string>;
}
export interface ReviveCompiler {
plan(input: ReviveCompileInputs, ports?: ReviveCompileResolvePorts): Promise<RevivePlan>;
emit(plan: RevivePlan): string;
compile(input: ReviveCompileInputs, ports?: ReviveCompileResolvePorts): Promise<string>;
/** Re-derives the effective tag for one file. Returns null when unreadable or indeterminate. */
recomputeOwnership(absoluteFilePath: string, filePath: string, input: Pick<ReviveCompileInputs, "tagSource" | "resolveTag">): string | false | null;
}
export declare function createReviveCompiler(ports: ReviveCompilerPorts, runtimePath: string): ReviveCompiler;