Fix server component stale caching. Add server components to SSR bundler

This commit is contained in:
2026-04-19 09:04:55 +01:00
parent 41e28d7a3e
commit 95fcee36b2
17 changed files with 228 additions and 27 deletions
@@ -8,6 +8,10 @@ import { log } from "../../../utils/log";
import grabRootFilePath from "./grab-root-file-path";
import grabPageServerRes from "./grab-page-server-res";
import grabPageServerPath from "./grab-page-server-path";
import path from "path";
import grabDirNames from "../../../utils/grab-dir-names";
const { ROOT_DIR } = grabDirNames();
type Params = {
file_path: string;
@@ -30,8 +34,14 @@ export default async function grabPageCombinedServerRes({
const { server_file_path: root_server_file_path } = root_file_path
? grabPageServerPath({ file_path: root_file_path })
: {};
const root_server_module: BunextPageServerModule = root_server_file_path
? await import(`${root_server_file_path}?t=${now}`)
const root_server_ctx_map =
global.SSR_BUNDLER_CTX_MAP[root_server_file_path || ""];
const final_root_server_path = root_server_ctx_map?.local_path
? path.join(ROOT_DIR, root_server_ctx_map.path)
: root_server_file_path;
const root_server_module: BunextPageServerModule = final_root_server_path
? await import(`${final_root_server_path}?t=${now}`)
: undefined;
const root_server_fn =
@@ -50,8 +60,13 @@ export default async function grabPageCombinedServerRes({
}
const { server_file_path } = grabPageServerPath({ file_path });
const server_module: BunextPageServerModule = server_file_path
? await import(`${server_file_path}?t=${now}`)
const page_server_ctx = global.SSR_BUNDLER_CTX_MAP[server_file_path || ""];
const final_page_server_path = page_server_ctx?.local_path
? path.join(ROOT_DIR, page_server_ctx.path)
: root_server_file_path;
const server_module: BunextPageServerModule = final_page_server_path
? await import(`${final_page_server_path}?t=${now}`)
: undefined;
const server_fn = server_module?.default || server_module?.server;