chore: clean up esbuild builder logic (#1231)

This will allow us to add various caches and similar around the esbuild
builder easily in follow up PRs.

It also makes doing an AOT build-step + load assets from disk much
simpler.
This commit is contained in:
Luca Casonato
2023-06-03 10:24:15 +02:00
committed by GitHub
parent 736c5524d5
commit 3857a49f1c
7 changed files with 318 additions and 217 deletions
+23
View File
@@ -0,0 +1,23 @@
export {
EsbuildBuilder,
type EsbuildBuilderOptions,
EsbuildSnapshot,
type JSXConfig,
} from "./esbuild.ts";
export interface Builder {
build(): Promise<BuildSnapshot>;
}
export interface BuildSnapshot {
/** The list of files contained in this snapshot, not prefixed by a slash. */
readonly paths: string[];
/** For a given file, return it's contents.
* @throws If the file is not contained in this snapshot. */
read(path: string): ReadableStream<Uint8Array> | Uint8Array | null;
/** For a given entrypoint, return it's list of dependencies.
*
* Returns an empty array if the entrypoint does not exist. */
dependencies(path: string): string[];
}