Rename global variables
This commit is contained in:
+2
-2
@@ -48,13 +48,13 @@ export default async function genWebHTML({ component: Main, pageProps, bundledMa
|
||||
env: {
|
||||
NODE_ENV: dev ? "development" : "production",
|
||||
...public_envs,
|
||||
...global.CONFIG.public_envs,
|
||||
...global.BUNEXT_CONFIG.public_envs,
|
||||
},
|
||||
};
|
||||
let final_component = (_jsxs("html", { ...html_props, children: [_jsxs("head", { children: [_jsx("meta", { charSet: "utf-8", "data-bunext-head": true }), _jsx("meta", { name: "viewport", content: "width=device-width, initial-scale=1.0", "data-bunext-head": true }), final_meta ? grabWebMetaHTML({ meta: final_meta }) : null, bundledMap?.css_path ? (_jsx("link", { rel: "stylesheet", href: `/${bundledMap.css_path}`, "data-bunext-head": true })) : null, _jsx("script", { dangerouslySetInnerHTML: {
|
||||
__html: `window.${ClientWindowPagePropsName} = ${serializedProps};\nwindow.process = ${JSON.stringify(client_process)}`,
|
||||
}, "data-bunext-head": true }), RootHead ? (_jsx(RootHead, { serverRes: pageProps, ctx: routeParams })) : null, Head ? _jsx(Head, { serverRes: pageProps, ctx: routeParams }) : null, bundledMap?.path ? (_jsxs(_Fragment, { children: [_jsx("script", { type: "importmap", dangerouslySetInnerHTML: {
|
||||
__html: JSON.stringify(global.REACT_IMPORTS_MAP),
|
||||
__html: JSON.stringify(global.BUNEXT_REACT_IMPORTS_MAP),
|
||||
}, defer: true, "data-bunext-head": true }), _jsx("script", { src: `/${bundledMap.path}`, type: "module", id: AppData["BunextClientHydrationScriptID"], defer: true, "data-bunext-head": true })] })) : null, is_dev ? (_jsx("script", { defer: true, dangerouslySetInnerHTML: {
|
||||
__html: page_hydration_script,
|
||||
}, "data-bunext-head": true })) : null] }), _jsx("body", { children: _jsx("div", { id: ClientRootElementIDName, suppressHydrationWarning: !dev, children: _jsx(Main, { ...pageProps }) }) })] }));
|
||||
|
||||
@@ -7,8 +7,8 @@ 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 abs = path.join(ROOT_DIR, global.SSR_BUNDLER_CTX_MAP[file_path].path);
|
||||
if (global.BUNEXT_SSR_BUNDLER_CTX_MAP?.[file_path]) {
|
||||
const abs = path.join(ROOT_DIR, global.BUNEXT_SSR_BUNDLER_CTX_MAP[file_path].path);
|
||||
// Loader.registry.delete(abs);
|
||||
const mod = await import(`${abs}?t=${Date.now()}`);
|
||||
const Main = mod.default;
|
||||
|
||||
@@ -12,7 +12,7 @@ export default async function grabPageCombinedServerRes({ file_path, debug, url,
|
||||
const { server_file_path: root_server_file_path } = root_file_path
|
||||
? grabPageServerPath({ file_path: root_file_path })
|
||||
: {};
|
||||
const root_server_ctx_map = global.SSR_BUNDLER_CTX_MAP[root_server_file_path || ""];
|
||||
const root_server_ctx_map = global.BUNEXT_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;
|
||||
@@ -33,7 +33,7 @@ export default async function grabPageCombinedServerRes({ file_path, debug, url,
|
||||
log.info(`rootServerRes:`, rootServerRes);
|
||||
}
|
||||
const { server_file_path } = grabPageServerPath({ file_path });
|
||||
const page_server_ctx = global.SSR_BUNDLER_CTX_MAP[server_file_path || ""];
|
||||
const page_server_ctx = global.BUNEXT_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)
|
||||
: server_file_path;
|
||||
|
||||
+10
-9
@@ -20,7 +20,7 @@ class NotFoundError extends Error {
|
||||
export default async function grabPageComponent(params) {
|
||||
const { req, file_path: passed_file_path, debug, return_server_res_only, skip_server_res, is_hydration, } = params;
|
||||
const url = req?.url ? new URL(req.url) : undefined;
|
||||
const router = global.ROUTER;
|
||||
const router = global.BUNEXT_ROUTER;
|
||||
const is_dev = isDevelopment();
|
||||
const forwarded_proto = req?.headers.get("x-forwarded-proto");
|
||||
if (url && forwarded_proto) {
|
||||
@@ -50,7 +50,7 @@ export default async function grabPageComponent(params) {
|
||||
// log.error(errMsg);
|
||||
throw new Error(errMsg);
|
||||
}
|
||||
let bundledMap = global.BUNDLER_CTX_MAP[file_path];
|
||||
let bundledMap = global.BUNEXT_BUNDLER_CTX_MAP[file_path];
|
||||
if (!bundledMap?.path) {
|
||||
if (does_error_file_exist) {
|
||||
throw new Error(`Application Error. Please Check your components. ${match?.filePath} likely exists but has no exported module.`);
|
||||
@@ -62,7 +62,7 @@ export default async function grabPageComponent(params) {
|
||||
msg: `Retrying Bundle map for file \`${file_path}\``,
|
||||
});
|
||||
await Bun.sleep(1000);
|
||||
bundledMap = global.BUNDLER_CTX_MAP[file_path];
|
||||
bundledMap = global.BUNEXT_BUNDLER_CTX_MAP[file_path];
|
||||
if (bundledMap?.path)
|
||||
break;
|
||||
}
|
||||
@@ -73,7 +73,7 @@ export default async function grabPageComponent(params) {
|
||||
}
|
||||
}
|
||||
if (req && !is_hydration) {
|
||||
global.BUNDLER_CTX_MAP[file_path].req_url = req.url;
|
||||
global.BUNEXT_BUNDLER_CTX_MAP[file_path].req_url = req.url;
|
||||
}
|
||||
if (debug) {
|
||||
log.info(`bundledMap:`, bundledMap);
|
||||
@@ -115,8 +115,9 @@ export default async function grabPageComponent(params) {
|
||||
error?.name === "NotFoundError" ||
|
||||
error?.status === 404;
|
||||
if (!params.retry && is_dev) {
|
||||
while (global.REBUILD_RETRIES < 2) {
|
||||
global.REBUILD_RETRIES = global.REBUILD_RETRIES + 1;
|
||||
while (global.BUNEXT_REBUILD_RETRIES < 2) {
|
||||
global.BUNEXT_REBUILD_RETRIES =
|
||||
global.BUNEXT_REBUILD_RETRIES + 1;
|
||||
await fullRebuild();
|
||||
await Bun.sleep(200);
|
||||
const component_retried = await grabPageComponent({
|
||||
@@ -125,15 +126,15 @@ export default async function grabPageComponent(params) {
|
||||
});
|
||||
if (component_retried instanceof Response ||
|
||||
component_retried.success) {
|
||||
global.REBUILD_RETRIES = 0;
|
||||
global.BUNEXT_REBUILD_RETRIES = 0;
|
||||
await serverPostBuildFn();
|
||||
return component_retried;
|
||||
}
|
||||
}
|
||||
global.REBUILD_RETRIES = 0;
|
||||
global.BUNEXT_REBUILD_RETRIES = 0;
|
||||
}
|
||||
if (is404) {
|
||||
global.IS_404_PAGE = true;
|
||||
global.BUNEXT_IS_404_PAGE = true;
|
||||
}
|
||||
else {
|
||||
log.error(`Error Grabbing Page Component: ${error.message}`);
|
||||
|
||||
@@ -3,7 +3,7 @@ import grabDirNames from "../../../utils/grab-dir-names";
|
||||
import grabPageModules from "./grab-page-modules";
|
||||
import _ from "lodash";
|
||||
export default async function grabPageErrorComponent({ error, routeParams, is404, url, }) {
|
||||
const router = global.ROUTER;
|
||||
const router = global.BUNEXT_ROUTER;
|
||||
const { BUNX_ROOT_500_PRESET_COMPONENT, BUNX_ROOT_404_PRESET_COMPONENT } = grabDirNames();
|
||||
const errorRoute = is404 ? "/404" : "/500";
|
||||
const presetComponent = is404
|
||||
@@ -30,7 +30,7 @@ export default async function grabPageErrorComponent({ error, routeParams, is404
|
||||
};
|
||||
}
|
||||
const file_path = match.filePath;
|
||||
const bundledMap = global.BUNDLER_CTX_MAP?.[file_path];
|
||||
const bundledMap = global.BUNEXT_BUNDLER_CTX_MAP?.[file_path];
|
||||
const page_component = await grabPageModules({
|
||||
file_path: file_path,
|
||||
query: match?.query,
|
||||
|
||||
@@ -108,11 +108,12 @@ async function loadEntry(page_file_path) {
|
||||
const now = Date.now();
|
||||
const mod_file_path = toModPath(page_file_path);
|
||||
const mod_css_path = mod_file_path.replace(/\.js$/, ".css");
|
||||
if (global.REACT_DOM_MODULE_CACHE.has(page_file_path)) {
|
||||
return global.REACT_DOM_MODULE_CACHE.get(page_file_path)?.main;
|
||||
if (global.BUNEXT_REACT_DOM_MODULE_CACHE.has(page_file_path)) {
|
||||
return global.BUNEXT_REACT_DOM_MODULE_CACHE.get(page_file_path)
|
||||
?.main;
|
||||
}
|
||||
const mod = await import(`${mod_file_path}?t=${now}`);
|
||||
global.REACT_DOM_MODULE_CACHE.set(page_file_path, {
|
||||
global.BUNEXT_REACT_DOM_MODULE_CACHE.set(page_file_path, {
|
||||
main: mod,
|
||||
css: mod_css_path,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user