Bugfix. Extract react imports from main bundler to vendor static files

This commit is contained in:
2026-04-08 05:39:11 +01:00
parent c19b7c9607
commit 4b3a4dbc77
38 changed files with 825 additions and 253 deletions
+18 -3
View File
@@ -31,7 +31,14 @@ export default async function ({ req }: Params): Promise<Response> {
}
}
export function readFileResponse({ file_path }: { file_path: string }) {
type FileResponse = {
file_path: string;
cache?: {
duration?: "infinite" | number;
};
};
export function readFileResponse({ file_path, cache }: FileResponse) {
if (!existsSync(file_path)) {
return new Response(`Public File Doesn't Exist`, {
status: 404,
@@ -40,7 +47,15 @@ export function readFileResponse({ file_path }: { file_path: string }) {
const file = Bun.file(file_path);
// let res_opts: ResponseInit = {};
const headers = new Headers();
return new Response(file);
if (cache?.duration == "infinite" || (cache && !cache.duration)) {
headers.set("Cache-Control", "public, max-age=31536000, immutable");
} else if (cache?.duration) {
headers.set("Cache-Control", `public, max-age=${cache.duration}`);
}
return new Response(file, {
headers,
});
}