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
+3 -3
View File
@@ -26,7 +26,7 @@ export interface RenderOptions<Data> {
plugins: Plugin[];
app: AppModule;
imports: string[];
dependencyMap: Map<string, string[]>;
dependenciesFn: (path: string) => string[];
url: URL;
params: Record<string, string | string[]>;
renderFn: RenderFunction;
@@ -221,8 +221,8 @@ export async function render<Data>(
const url = bundleAssetUrl(path);
imports.push([url, randomNonce]);
preloadSet.add(url);
for (const depPath of opts.dependencyMap.get(path) ?? []) {
const url = bundleAssetUrl(depPath);
for (const depPath of opts.dependenciesFn(path)) {
const url = bundleAssetUrl(`/${depPath}`);
preloadSet.add(url);
}
return url;