Bugfix: Refactor SSR bundler. Fix stale cache SSR modules.
This commit is contained in:
@@ -2,8 +2,16 @@ import grabPageReactComponentString from "./grab-page-react-component-string";
|
||||
import grabTsxStringModule from "./grab-tsx-string-module";
|
||||
import { log } from "../../../utils/log";
|
||||
import grabRootFilePath from "./grab-root-file-path";
|
||||
import path from "path";
|
||||
import grabDirNames from "../../../utils/grab-dir-names";
|
||||
const { ROOT_DIR } = grabDirNames();
|
||||
export default async function grabPageBundledReactComponent({ file_path, return_tsx_only, }) {
|
||||
try {
|
||||
if (global.SSR_BUNDLER_CTX_MAP?.[file_path]) {
|
||||
const mod = await import(path.join(ROOT_DIR, global.SSR_BUNDLER_CTX_MAP[file_path].path));
|
||||
const Main = mod.default;
|
||||
return { component: Main };
|
||||
}
|
||||
const { root_file_path } = grabRootFilePath();
|
||||
let tsx = grabPageReactComponentString({
|
||||
file_path,
|
||||
|
||||
@@ -1,19 +1,12 @@
|
||||
import EJSON from "../../../utils/ejson";
|
||||
import { log } from "../../../utils/log";
|
||||
export default function grabPageReactComponentString({ file_path, root_file_path,
|
||||
// server_res,
|
||||
}) {
|
||||
export default function grabPageReactComponentString({ file_path, root_file_path, }) {
|
||||
try {
|
||||
let tsx = ``;
|
||||
// const server_res_json = JSON.stringify(
|
||||
// EJSON.stringify(server_res || {}) ?? "{}",
|
||||
// );
|
||||
if (root_file_path) {
|
||||
tsx += `import Root from "${root_file_path}"\n`;
|
||||
}
|
||||
tsx += `import Page from "${file_path}"\n`;
|
||||
tsx += `export default function Main({...props}) {\n\n`;
|
||||
// tsx += `const props = JSON.parse(${server_res_json})\n\n`;
|
||||
tsx += ` return (\n`;
|
||||
if (root_file_path) {
|
||||
tsx += ` <Root {...props}><Page {...props} /></Root>\n`;
|
||||
|
||||
Reference in New Issue
Block a user