Rename global variables
This commit is contained in:
@@ -80,7 +80,7 @@ export default async function genWebHTML({
|
||||
env: {
|
||||
NODE_ENV: dev ? "development" : "production",
|
||||
...public_envs,
|
||||
...global.CONFIG.public_envs,
|
||||
...global.BUNEXT_CONFIG.public_envs,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -122,7 +122,7 @@ export default async function genWebHTML({
|
||||
type="importmap"
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: JSON.stringify(
|
||||
global.REACT_IMPORTS_MAP,
|
||||
global.BUNEXT_REACT_IMPORTS_MAP,
|
||||
),
|
||||
}}
|
||||
defer
|
||||
|
||||
@@ -19,10 +19,10 @@ export default async function grabPageBundledReactComponent({
|
||||
return_tsx_only,
|
||||
}: Params): Promise<GrabPageReactBundledComponentRes | undefined> {
|
||||
try {
|
||||
if (global.SSR_BUNDLER_CTX_MAP?.[file_path]) {
|
||||
if (global.BUNEXT_SSR_BUNDLER_CTX_MAP?.[file_path]) {
|
||||
const abs = path.join(
|
||||
ROOT_DIR,
|
||||
global.SSR_BUNDLER_CTX_MAP[file_path].path,
|
||||
global.BUNEXT_SSR_BUNDLER_CTX_MAP[file_path].path,
|
||||
);
|
||||
// Loader.registry.delete(abs);
|
||||
const mod = await import(`${abs}?t=${Date.now()}`);
|
||||
|
||||
@@ -35,7 +35,7 @@ export default async function grabPageCombinedServerRes({
|
||||
? grabPageServerPath({ file_path: root_file_path })
|
||||
: {};
|
||||
const root_server_ctx_map =
|
||||
global.SSR_BUNDLER_CTX_MAP[root_server_file_path || ""];
|
||||
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;
|
||||
@@ -63,7 +63,8 @@ export default async function grabPageCombinedServerRes({
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
@@ -45,7 +45,7 @@ export default async function grabPageComponent(
|
||||
} = 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");
|
||||
@@ -89,7 +89,7 @@ export default async function grabPageComponent(
|
||||
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) {
|
||||
@@ -106,7 +106,7 @@ export default async function grabPageComponent(
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@ export default async function grabPageComponent(
|
||||
}
|
||||
|
||||
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) {
|
||||
@@ -168,8 +168,9 @@ export default async function grabPageComponent(
|
||||
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);
|
||||
@@ -182,17 +183,17 @@ export default async function grabPageComponent(
|
||||
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}`);
|
||||
log.error(`Page: ${passed_file_path || url?.pathname}`);
|
||||
|
||||
@@ -21,7 +21,7 @@ export default async function grabPageErrorComponent({
|
||||
is404,
|
||||
url,
|
||||
}: Params): Promise<GrabPageComponentRes | Response> {
|
||||
const router = global.ROUTER;
|
||||
const router = global.BUNEXT_ROUTER;
|
||||
|
||||
const { BUNX_ROOT_500_PRESET_COMPONENT, BUNX_ROOT_404_PRESET_COMPONENT } =
|
||||
grabDirNames();
|
||||
@@ -59,7 +59,7 @@ export default async function grabPageErrorComponent({
|
||||
|
||||
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,
|
||||
|
||||
@@ -148,13 +148,14 @@ async function loadEntry<T>(page_file_path: string): Promise<T> {
|
||||
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 as T;
|
||||
if (global.BUNEXT_REACT_DOM_MODULE_CACHE.has(page_file_path)) {
|
||||
return global.BUNEXT_REACT_DOM_MODULE_CACHE.get(page_file_path)
|
||||
?.main as T;
|
||||
}
|
||||
|
||||
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