Component Bundler Bugfix

This commit is contained in:
2026-04-04 20:30:40 +01:00
parent 1037bbb546
commit 5166ba037f
8 changed files with 118 additions and 91 deletions
@@ -1,12 +1,11 @@
import EJSON from "../../../utils/ejson";
import isDevelopment from "../../../utils/is-development";
import { log } from "../../../utils/log";
import pagePathTransform from "../../../utils/page-path-transform";
export default function grabPageReactComponentString({ file_path, root_file_path, server_res, }) {
const now = Date.now();
const dev = isDevelopment();
try {
// const target_path = pagePathTransform({ page_path: file_path });
// const target_root_path = root_file_path
// ? pagePathTransform({ page_path: root_file_path })
// : undefined;
const import_suffix = dev ? `?t=${now}` : "";
let tsx = ``;
const server_res_json = JSON.stringify(EJSON.stringify(server_res || {}) ?? "{}");
// Import Root from its original source path so that all sub-components
@@ -15,9 +14,9 @@ export default function grabPageReactComponentString({ file_path, root_file_path
// createContext() call, breaking context for any sub-component that
// imports AppContext via a relative path to the source __root.
if (root_file_path) {
tsx += `import Root from "${root_file_path}"\n`;
tsx += `import Root from "${root_file_path}${import_suffix}"\n`;
}
tsx += `import Page from "${file_path}"\n`;
tsx += `import Page from "${file_path}${import_suffix}"\n`;
tsx += `export default function Main() {\n\n`;
tsx += `const props = JSON.parse(${server_res_json})\n\n`;
tsx += ` return (\n`;