Rename global variables
This commit is contained in:
@@ -9,7 +9,7 @@ const BunSkipNonBrowserPlugin: Bun.BunPlugin = {
|
||||
// const skipped_modules = new Set<string>();
|
||||
|
||||
build.onResolve({ filter: skipFilter }, (args) => {
|
||||
global.SKIPPED_BROWSER_MODULES.add(args.path);
|
||||
global.BUNEXT_SKIPPED_BROWSER_MODULES.add(args.path);
|
||||
return {
|
||||
path: args.path,
|
||||
namespace: "skipped",
|
||||
@@ -18,8 +18,8 @@ const BunSkipNonBrowserPlugin: Bun.BunPlugin = {
|
||||
});
|
||||
|
||||
// build.onEnd(() => {
|
||||
// log.warn(`global.SKIPPED_BROWSER_MODULES`, [
|
||||
// ...global.SKIPPED_BROWSER_MODULES,
|
||||
// log.warn(`global.BUNEXT_SKIPPED_BROWSER_MODULES`, [
|
||||
// ...global.BUNEXT_SKIPPED_BROWSER_MODULES,
|
||||
// ]);
|
||||
// });
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ export default function esbuildCTXArtifactTracker({
|
||||
name: "artifact-tracker",
|
||||
setup(build) {
|
||||
build.onStart(async () => {
|
||||
global.MAIN_CTX_BUILD_STARTS++;
|
||||
global.BUNEXT_MAIN_CTX_BUILD_STARTS++;
|
||||
build_start = performance.now();
|
||||
|
||||
const does_error_file_exist = existsSync(
|
||||
@@ -44,7 +44,7 @@ export default function esbuildCTXArtifactTracker({
|
||||
);
|
||||
|
||||
if (
|
||||
global.MAIN_CTX_BUILD_STARTS >= MAX_BUILD_STARTS &&
|
||||
global.BUNEXT_MAIN_CTX_BUILD_STARTS >= MAX_BUILD_STARTS &&
|
||||
!does_error_file_exist
|
||||
) {
|
||||
await buildOnstartErrorHandler();
|
||||
@@ -53,8 +53,8 @@ export default function esbuildCTXArtifactTracker({
|
||||
|
||||
build.onEnd(async (result) => {
|
||||
if (result.errors.length > 0) {
|
||||
global.RECOMPILING = false;
|
||||
global.IS_SERVER_COMPONENT = false;
|
||||
global.BUNEXT_RECOMPILING = false;
|
||||
global.BUNEXT_IS_SERVER_COMPONENT = false;
|
||||
|
||||
log.error(`Build errors:`);
|
||||
for (const err of result.errors) {
|
||||
@@ -64,17 +64,17 @@ export default function esbuildCTXArtifactTracker({
|
||||
}
|
||||
|
||||
for (
|
||||
let i = global.HMR_CONTROLLERS.length - 1;
|
||||
let i = global.BUNEXT_HMR_CONTROLLERS.length - 1;
|
||||
i >= 0;
|
||||
i--
|
||||
) {
|
||||
const controller = global.HMR_CONTROLLERS[i];
|
||||
const controller = global.BUNEXT_HMR_CONTROLLERS[i];
|
||||
try {
|
||||
controller?.controller?.enqueue(
|
||||
`event: update\ndata: ${JSON.stringify({ reload: true })}\n\n`,
|
||||
);
|
||||
} catch {
|
||||
global.HMR_CONTROLLERS.splice(i, 1);
|
||||
global.BUNEXT_HMR_CONTROLLERS.splice(i, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,10 +89,15 @@ export default function esbuildCTXArtifactTracker({
|
||||
if (artifacts?.[0] && artifacts.length > 0) {
|
||||
for (let i = 0; i < artifacts.length; i++) {
|
||||
const artifact = artifacts[i];
|
||||
if (artifact?.local_path && global.BUNDLER_CTX_MAP) {
|
||||
global.BUNDLER_CTX_MAP[artifact.local_path] =
|
||||
if (
|
||||
artifact?.local_path &&
|
||||
global.BUNEXT_BUNDLER_CTX_MAP
|
||||
) {
|
||||
global.BUNEXT_BUNDLER_CTX_MAP[artifact.local_path] =
|
||||
_.merge(
|
||||
global.BUNDLER_CTX_MAP[artifact.local_path],
|
||||
global.BUNEXT_BUNDLER_CTX_MAP[
|
||||
artifact.local_path
|
||||
],
|
||||
artifact,
|
||||
);
|
||||
}
|
||||
@@ -102,8 +107,8 @@ export default function esbuildCTXArtifactTracker({
|
||||
const elapsed = (performance.now() - build_start).toFixed(0);
|
||||
log.success(`[Built] in ${elapsed}ms`);
|
||||
|
||||
global.MAIN_CTX_BUILD_STARTS = 0;
|
||||
global.BUNDLER_CTX_DISPOSED = false;
|
||||
global.BUNEXT_MAIN_CTX_BUILD_STARTS = 0;
|
||||
global.BUNEXT_BUNDLER_CTX_DISPOSED = false;
|
||||
|
||||
const does_error_file_exist = existsSync(
|
||||
BUNX_BUNDLER_ERROR_EXIT_FILE,
|
||||
@@ -141,8 +146,8 @@ export default function esbuildCTXArtifactTracker({
|
||||
}
|
||||
}
|
||||
|
||||
global.RECOMPILING = false;
|
||||
global.IS_SERVER_COMPONENT = false;
|
||||
global.BUNEXT_RECOMPILING = false;
|
||||
global.BUNEXT_IS_SERVER_COMPONENT = false;
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
@@ -32,19 +32,19 @@ export default function ssrCTXArtifactTracker({
|
||||
build_starts++;
|
||||
build_start = performance.now();
|
||||
if (build_starts == MAX_BUILD_STARTS) {
|
||||
global.SSR_BUNDLER_CTX_DISPOSED = true;
|
||||
await global.SSR_BUNDLER_CTX?.dispose();
|
||||
global.SSR_BUNDLER_CTX = undefined;
|
||||
global.BUNEXT_SSR_BUNDLER_CTX_DISPOSED = true;
|
||||
await global.BUNEXT_SSR_BUNDLER_CTX?.dispose();
|
||||
global.BUNEXT_SSR_BUNDLER_CTX = undefined;
|
||||
}
|
||||
});
|
||||
|
||||
build.onEnd(async (result) => {
|
||||
if (result.errors.length > 0) {
|
||||
global.SSR_BUNDLER_CTX_DISPOSED = true;
|
||||
global.BUNEXT_SSR_BUNDLER_CTX_DISPOSED = true;
|
||||
try {
|
||||
await global.SSR_BUNDLER_CTX?.dispose();
|
||||
await global.BUNEXT_SSR_BUNDLER_CTX?.dispose();
|
||||
} catch {}
|
||||
global.SSR_BUNDLER_CTX = undefined;
|
||||
global.BUNEXT_SSR_BUNDLER_CTX = undefined;
|
||||
build_starts = 0;
|
||||
for (const err of result.errors) {
|
||||
console.error(
|
||||
@@ -65,10 +65,11 @@ export default function ssrCTXArtifactTracker({
|
||||
const artifact = artifacts[i];
|
||||
if (
|
||||
artifact?.local_path &&
|
||||
global.SSR_BUNDLER_CTX_MAP
|
||||
global.BUNEXT_SSR_BUNDLER_CTX_MAP
|
||||
) {
|
||||
global.SSR_BUNDLER_CTX_MAP[artifact.local_path] =
|
||||
artifact;
|
||||
global.BUNEXT_SSR_BUNDLER_CTX_MAP[
|
||||
artifact.local_path
|
||||
] = artifact;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,11 +84,15 @@ export default function ssrCTXArtifactTracker({
|
||||
try {
|
||||
writeFileSync(
|
||||
path.join(BUNX_TMP_DIR, "ctx-map.json"),
|
||||
JSON.stringify(global.SSR_BUNDLER_CTX_MAP, null, 4),
|
||||
JSON.stringify(
|
||||
global.BUNEXT_SSR_BUNDLER_CTX_MAP,
|
||||
null,
|
||||
4,
|
||||
),
|
||||
);
|
||||
} catch (error) {}
|
||||
|
||||
global.SSR_BUNDLER_CTX_DISPOSED = false;
|
||||
global.BUNEXT_SSR_BUNDLER_CTX_DISPOSED = false;
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user