fix: serve internal JS from path containing build ID (#2753)

Previously imported chunks were not cached at all. They are now cached
properly with immutable cache headers.
This commit is contained in:
Luca Casonato
2024-11-08 11:44:15 +01:00
committed by GitHub
parent 96e520a352
commit 6b685dde9f
6 changed files with 42 additions and 27 deletions
+4 -2
View File
@@ -182,9 +182,11 @@ export class Builder implements FreshBuilder {
denoJsonPath: denoJson.filePath,
});
const prefix = `/_fresh/js/${BUILD_ID}/`;
for (let i = 0; i < output.files.length; i++) {
const file = output.files[i];
const pathname = `/${file.path}`;
const pathname = `${prefix}${file.path}`;
await buildCache.addProcessedFile(pathname, file.contents, file.hash);
}
@@ -196,7 +198,7 @@ export class Builder implements FreshBuilder {
`Missing chunk for ${island.file}#${island.exportName}`,
);
}
buildCache.islands.set(island.name, `/${chunk}`);
buildCache.islands.set(island.name, `${prefix}${chunk}`);
}
await buildCache.flush();