Refactor start and dev commands. Start in child processes. Handle errors better
This commit is contained in:
parent
a5f25d522e
commit
9a427412f3
1
dist/commands/dev/dev-spawn.d.ts
vendored
Normal file
1
dist/commands/dev/dev-spawn.d.ts
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
export {};
|
||||||
14
dist/commands/dev/dev-spawn.js
vendored
Normal file
14
dist/commands/dev/dev-spawn.js
vendored
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
import startServer from "../../functions/server/start-server";
|
||||||
|
import { log } from "../../utils/log";
|
||||||
|
import bunextInit from "../../functions/bunext-init";
|
||||||
|
import grabDirNames from "../../utils/grab-dir-names";
|
||||||
|
import { rmSync } from "fs";
|
||||||
|
const { HYDRATION_DST_DIR, BUNX_CWD_PAGES_REWRITE_DIR } = grabDirNames();
|
||||||
|
log.info("Running development server ...");
|
||||||
|
try {
|
||||||
|
rmSync(HYDRATION_DST_DIR, { recursive: true });
|
||||||
|
rmSync(BUNX_CWD_PAGES_REWRITE_DIR, { recursive: true });
|
||||||
|
}
|
||||||
|
catch (error) { }
|
||||||
|
await bunextInit();
|
||||||
|
await startServer();
|
||||||
36
dist/commands/dev/index.js
vendored
36
dist/commands/dev/index.js
vendored
@ -1,22 +1,30 @@
|
|||||||
import { Command } from "commander";
|
import { Command } from "commander";
|
||||||
import startServer from "../../functions/server/start-server";
|
import path from "path";
|
||||||
import { log } from "../../utils/log";
|
|
||||||
import bunextInit from "../../functions/bunext-init";
|
|
||||||
import grabDirNames from "../../utils/grab-dir-names";
|
import grabDirNames from "../../utils/grab-dir-names";
|
||||||
import { rmSync } from "fs";
|
import writeErrorFile from "../../functions/write-error-file";
|
||||||
const { HYDRATION_DST_DIR, BUNX_CWD_PAGES_REWRITE_DIR, BUNX_CWD_MODULE_CACHE_DIR, } = grabDirNames();
|
|
||||||
export default function () {
|
export default function () {
|
||||||
return new Command("dev")
|
return new Command("dev")
|
||||||
.description("Run development server")
|
.description("Run development server")
|
||||||
.action(async () => {
|
.action(async () => {
|
||||||
process.env.NODE_ENV = "development";
|
await dev();
|
||||||
log.info("Running development server ...");
|
|
||||||
try {
|
|
||||||
rmSync(HYDRATION_DST_DIR, { recursive: true });
|
|
||||||
rmSync(BUNX_CWD_PAGES_REWRITE_DIR, { recursive: true });
|
|
||||||
}
|
|
||||||
catch (error) { }
|
|
||||||
await bunextInit();
|
|
||||||
await startServer();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
async function dev() {
|
||||||
|
const dev_spawn_file = path.resolve(__dirname, "dev-spawn.ts");
|
||||||
|
const spawn_options = {
|
||||||
|
cmd: ["bun", dev_spawn_file],
|
||||||
|
stdio: ["inherit", "inherit", "inherit"],
|
||||||
|
onExit(subprocess, exitCode, signalCode, error) {
|
||||||
|
writeErrorFile({ exitCode, error });
|
||||||
|
},
|
||||||
|
env: {
|
||||||
|
...process.env,
|
||||||
|
NODE_ENV: "development",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
let dev_process = Bun.spawn(spawn_options);
|
||||||
|
const exited = await dev_process.exited;
|
||||||
|
if (exited) {
|
||||||
|
return await dev();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
29
dist/commands/start/index.js
vendored
29
dist/commands/start/index.js
vendored
@ -1,14 +1,29 @@
|
|||||||
import { Command } from "commander";
|
import { Command } from "commander";
|
||||||
import startServer from "../../functions/server/start-server";
|
import path from "path";
|
||||||
import { log } from "../../utils/log";
|
import writeErrorFile from "../../functions/write-error-file";
|
||||||
import bunextInit from "../../functions/bunext-init";
|
|
||||||
export default function () {
|
export default function () {
|
||||||
return new Command("start")
|
return new Command("start")
|
||||||
.description("Start production server")
|
.description("Start production server")
|
||||||
.action(async () => {
|
.action(async () => {
|
||||||
process.env.NODE_ENV = "production";
|
await start();
|
||||||
log.info("Starting production server ...");
|
|
||||||
await bunextInit();
|
|
||||||
await startServer();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
async function start() {
|
||||||
|
const dev_spawn_file = path.resolve(__dirname, "prod-spawn.ts");
|
||||||
|
const spawn_options = {
|
||||||
|
cmd: ["bun", dev_spawn_file],
|
||||||
|
stdio: ["inherit", "inherit", "inherit"],
|
||||||
|
onExit(subprocess, exitCode, signalCode, error) {
|
||||||
|
writeErrorFile({ exitCode, error });
|
||||||
|
},
|
||||||
|
env: {
|
||||||
|
...process.env,
|
||||||
|
NODE_ENV: "production",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
let dev_process = Bun.spawn(spawn_options);
|
||||||
|
const exited = await dev_process.exited;
|
||||||
|
if (exited) {
|
||||||
|
return await start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
1
dist/commands/start/prod-spawn.d.ts
vendored
Normal file
1
dist/commands/start/prod-spawn.d.ts
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
export {};
|
||||||
6
dist/commands/start/prod-spawn.js
vendored
Normal file
6
dist/commands/start/prod-spawn.js
vendored
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
import bunextInit from "../../functions/bunext-init";
|
||||||
|
import startServer from "../../functions/server/start-server";
|
||||||
|
import { log } from "../../utils/log";
|
||||||
|
log.info("Starting production server ...");
|
||||||
|
await bunextInit();
|
||||||
|
await startServer();
|
||||||
1
dist/data/app-data.d.ts
vendored
1
dist/data/app-data.d.ts
vendored
@ -6,4 +6,5 @@ export declare const AppData: {
|
|||||||
readonly BunextClientHydrationScriptID: "bunext-client-hydration-script";
|
readonly BunextClientHydrationScriptID: "bunext-client-hydration-script";
|
||||||
readonly BunextTmpFileExt: ".bunext_tmp.tsx";
|
readonly BunextTmpFileExt: ".bunext_tmp.tsx";
|
||||||
readonly BunextHMRRetryRoute: "/.bunext/hmr-retry";
|
readonly BunextHMRRetryRoute: "/.bunext/hmr-retry";
|
||||||
|
readonly DefaultMaxLogs: 50;
|
||||||
};
|
};
|
||||||
|
|||||||
1
dist/data/app-data.js
vendored
1
dist/data/app-data.js
vendored
@ -6,4 +6,5 @@ export const AppData = {
|
|||||||
BunextClientHydrationScriptID: "bunext-client-hydration-script",
|
BunextClientHydrationScriptID: "bunext-client-hydration-script",
|
||||||
BunextTmpFileExt: ".bunext_tmp.tsx",
|
BunextTmpFileExt: ".bunext_tmp.tsx",
|
||||||
BunextHMRRetryRoute: "/.bunext/hmr-retry",
|
BunextHMRRetryRoute: "/.bunext/hmr-retry",
|
||||||
|
DefaultMaxLogs: 50,
|
||||||
};
|
};
|
||||||
|
|||||||
@ -7,9 +7,11 @@ import grabClientHydrationScript from "./grab-client-hydration-script";
|
|||||||
import path from "path";
|
import path from "path";
|
||||||
import virtualFilesPlugin from "./plugins/virtual-files-plugin";
|
import virtualFilesPlugin from "./plugins/virtual-files-plugin";
|
||||||
import esbuildCTXArtifactTracker from "./plugins/esbuild-ctx-artifact-tracker";
|
import esbuildCTXArtifactTracker from "./plugins/esbuild-ctx-artifact-tracker";
|
||||||
const { HYDRATION_DST_DIR, BUNX_HYDRATION_SRC_DIR } = grabDirNames();
|
import { existsSync } from "fs";
|
||||||
|
const { HYDRATION_DST_DIR, BUNX_HYDRATION_SRC_DIR, BUNX_BUNDLER_ERROR_EXIT_FILE, } = grabDirNames();
|
||||||
export default async function allPagesESBuildContextBundler(params) {
|
export default async function allPagesESBuildContextBundler(params) {
|
||||||
try {
|
try {
|
||||||
|
const did_process_exit_because_of_bundler_error = existsSync(BUNX_BUNDLER_ERROR_EXIT_FILE);
|
||||||
const pages = grabAllPages({ exclude_api: true });
|
const pages = grabAllPages({ exclude_api: true });
|
||||||
global.PAGE_FILES = pages;
|
global.PAGE_FILES = pages;
|
||||||
const dev = isDevelopment();
|
const dev = isDevelopment();
|
||||||
@ -59,6 +61,9 @@ export default async function allPagesESBuildContextBundler(params) {
|
|||||||
"react/jsx-runtime",
|
"react/jsx-runtime",
|
||||||
"react/jsx-dev-runtime",
|
"react/jsx-dev-runtime",
|
||||||
],
|
],
|
||||||
|
logLevel: did_process_exit_because_of_bundler_error
|
||||||
|
? "silent"
|
||||||
|
: undefined,
|
||||||
});
|
});
|
||||||
await global.BUNDLER_CTX.rebuild();
|
await global.BUNDLER_CTX.rebuild();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,9 +4,15 @@ import grabArtifactsFromBundledResults from "../grab-artifacts-from-bundled-resu
|
|||||||
import buildOnstartErrorHandler from "../build-on-start-error-handler";
|
import buildOnstartErrorHandler from "../build-on-start-error-handler";
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
import pagesSSRBundler from "../pages-ssr-bundler";
|
import pagesSSRBundler from "../pages-ssr-bundler";
|
||||||
|
import grabDirNames from "../../../utils/grab-dir-names";
|
||||||
|
import { cpSync, existsSync, mkdirSync, rmSync } from "fs";
|
||||||
|
import fullRebuild from "../../server/full-rebuild";
|
||||||
|
import path from "path";
|
||||||
|
import cleanupLogsDirs from "../../cleanup-logs-dir";
|
||||||
|
const { BUNX_BUNDLER_ERROR_EXIT_FILE, BUNX_ERROR_LOGS_DIR } = grabDirNames();
|
||||||
let build_start = 0;
|
let build_start = 0;
|
||||||
let build_starts = 0;
|
let build_starts = 0;
|
||||||
const MAX_BUILD_STARTS = 5;
|
const MAX_BUILD_STARTS = 2;
|
||||||
export default function esbuildCTXArtifactTracker({ entryToPage, post_build_fn, }) {
|
export default function esbuildCTXArtifactTracker({ entryToPage, post_build_fn, }) {
|
||||||
const artifactTracker = {
|
const artifactTracker = {
|
||||||
name: "artifact-tracker",
|
name: "artifact-tracker",
|
||||||
@ -14,8 +20,11 @@ export default function esbuildCTXArtifactTracker({ entryToPage, post_build_fn,
|
|||||||
build.onStart(async () => {
|
build.onStart(async () => {
|
||||||
build_starts++;
|
build_starts++;
|
||||||
build_start = performance.now();
|
build_start = performance.now();
|
||||||
if (build_starts == MAX_BUILD_STARTS) {
|
const does_error_file_exist = existsSync(BUNX_BUNDLER_ERROR_EXIT_FILE);
|
||||||
|
if (build_starts == MAX_BUILD_STARTS &&
|
||||||
|
!does_error_file_exist) {
|
||||||
await buildOnstartErrorHandler();
|
await buildOnstartErrorHandler();
|
||||||
|
process.exit(1);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
build.onEnd((result) => {
|
build.onEnd((result) => {
|
||||||
@ -41,7 +50,17 @@ export default function esbuildCTXArtifactTracker({ entryToPage, post_build_fn,
|
|||||||
global.RECOMPILING = false;
|
global.RECOMPILING = false;
|
||||||
global.IS_SERVER_COMPONENT = false;
|
global.IS_SERVER_COMPONENT = false;
|
||||||
build_starts = 0;
|
build_starts = 0;
|
||||||
pagesSSRBundler();
|
const does_error_file_exist = existsSync(BUNX_BUNDLER_ERROR_EXIT_FILE);
|
||||||
|
if (does_error_file_exist) {
|
||||||
|
mkdirSync(BUNX_ERROR_LOGS_DIR, { recursive: true });
|
||||||
|
cpSync(BUNX_BUNDLER_ERROR_EXIT_FILE, path.join(BUNX_ERROR_LOGS_DIR, `${Date.now()}.log`));
|
||||||
|
rmSync(BUNX_BUNDLER_ERROR_EXIT_FILE, { force: true });
|
||||||
|
cleanupLogsDirs();
|
||||||
|
fullRebuild();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
pagesSSRBundler();
|
||||||
|
}
|
||||||
// if (global.SSR_BUNDLER_CTX) {
|
// if (global.SSR_BUNDLER_CTX) {
|
||||||
// global.SSR_BUNDLER_CTX.rebuild();
|
// global.SSR_BUNDLER_CTX.rebuild();
|
||||||
// } else {
|
// } else {
|
||||||
|
|||||||
12
dist/functions/bunext-init.js
vendored
12
dist/functions/bunext-init.js
vendored
@ -48,9 +48,9 @@ export default async function bunextInit() {
|
|||||||
cron();
|
cron();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
process.on("exit", (code) => {
|
// process.on("exit", (code) => {
|
||||||
Bun.spawn([process.execPath, ...process.argv.slice(1)], {
|
// Bun.spawn([process.execPath, ...process.argv.slice(1)], {
|
||||||
stdio: ["inherit", "inherit", "inherit"],
|
// stdio: ["inherit", "inherit", "inherit"],
|
||||||
env: process.env,
|
// env: process.env,
|
||||||
});
|
// });
|
||||||
});
|
// });
|
||||||
|
|||||||
1
dist/functions/cleanup-logs-dir.d.ts
vendored
Normal file
1
dist/functions/cleanup-logs-dir.d.ts
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
export default function cleanupLogsDirs(): void;
|
||||||
48
dist/functions/cleanup-logs-dir.js
vendored
Normal file
48
dist/functions/cleanup-logs-dir.js
vendored
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
import path from "path";
|
||||||
|
import { mkdirSync, readdirSync, rmSync, statSync, writeFileSync } from "fs";
|
||||||
|
import grabDirNames from "../utils/grab-dir-names";
|
||||||
|
import grabConstants from "../utils/grab-constants";
|
||||||
|
import { AppData } from "../data/app-data";
|
||||||
|
const { BUNX_LOGS_DIR } = grabDirNames();
|
||||||
|
export default function cleanupLogsDirs() {
|
||||||
|
const logs_dirs = readdirSync(BUNX_LOGS_DIR);
|
||||||
|
const { config } = grabConstants();
|
||||||
|
const MAX_LOGS = config.max_logs || AppData["DefaultMaxLogs"];
|
||||||
|
for (let i = 0; i < logs_dirs.length; i++) {
|
||||||
|
const dir = logs_dirs[i];
|
||||||
|
const full_path = path.join(BUNX_LOGS_DIR, dir);
|
||||||
|
const path_stats = statSync(full_path);
|
||||||
|
if (!path_stats.isDirectory()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const sub_dir_files = readdirSync(full_path).sort((a, b) => {
|
||||||
|
const timestamp_a = Number(a.split(".")[0]);
|
||||||
|
const timestamp_b = Number(b.split(".")[0]);
|
||||||
|
if (timestamp_a > timestamp_b)
|
||||||
|
return 1;
|
||||||
|
return -1;
|
||||||
|
});
|
||||||
|
for (let j = 0; j < sub_dir_files.length; j++) {
|
||||||
|
const sub_dir_file = sub_dir_files[j];
|
||||||
|
const sub_dir_file_full_path = path.join(full_path, sub_dir_file);
|
||||||
|
const sub_dir_file_Stats = statSync(sub_dir_file_full_path);
|
||||||
|
if (!sub_dir_file_Stats.isFile()) {
|
||||||
|
rmSync(sub_dir_file_full_path, {
|
||||||
|
force: true,
|
||||||
|
recursive: true,
|
||||||
|
});
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (j > MAX_LOGS - 1) {
|
||||||
|
rmSync(sub_dir_file_full_path, { force: true });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// log.info("Running development server ...");
|
||||||
|
// try {
|
||||||
|
// rmSync(HYDRATION_DST_DIR, { recursive: true });
|
||||||
|
// rmSync(BUNX_CWD_PAGES_REWRITE_DIR, { recursive: true });
|
||||||
|
// } catch (error) {}
|
||||||
|
// await bunextInit();
|
||||||
|
// await startServer();
|
||||||
1
dist/functions/process.d.ts
vendored
Normal file
1
dist/functions/process.d.ts
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
export {};
|
||||||
46
dist/functions/process.js
vendored
Normal file
46
dist/functions/process.js
vendored
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
import { spawn } from "bun";
|
||||||
|
// Only the "supervisor" respawns. The child sets this env var so it won't respawn itself.
|
||||||
|
const IS_CHILD = process.env.__RESPAWN_CHILD === "1";
|
||||||
|
let shuttingDown = false;
|
||||||
|
async function cleanup() {
|
||||||
|
// Put real cleanup here: close DB handles, servers, file descriptors, timers, etc.
|
||||||
|
// Must be awaitable — do NOT rely on process.on("exit") for this.
|
||||||
|
}
|
||||||
|
function respawn(code) {
|
||||||
|
const child = spawn({
|
||||||
|
cmd: [process.execPath, ...process.argv.slice(1)],
|
||||||
|
stdio: ["inherit", "inherit", "inherit"],
|
||||||
|
env: { ...process.env, __RESPAWN_CHILD: "1" },
|
||||||
|
// Detach so the child survives independently and gets its own process group.
|
||||||
|
// Without this, killing the parent's group can take the child with it.
|
||||||
|
});
|
||||||
|
// Let the child live on its own.
|
||||||
|
child.unref?.();
|
||||||
|
}
|
||||||
|
async function shutdown(code) {
|
||||||
|
if (shuttingDown)
|
||||||
|
return;
|
||||||
|
shuttingDown = true;
|
||||||
|
try {
|
||||||
|
await cleanup();
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
console.error("cleanup failed:", e);
|
||||||
|
}
|
||||||
|
// Only the supervisor respawns, and only on abnormal exit.
|
||||||
|
if (!IS_CHILD && code !== 0) {
|
||||||
|
respawn(code);
|
||||||
|
}
|
||||||
|
process.exit(code);
|
||||||
|
}
|
||||||
|
// Catch the things that actually fire *before* exit, where async works.
|
||||||
|
process.on("SIGINT", () => shutdown(130));
|
||||||
|
process.on("SIGTERM", () => shutdown(143));
|
||||||
|
process.on("uncaughtException", (err) => {
|
||||||
|
console.error(err);
|
||||||
|
shutdown(1);
|
||||||
|
});
|
||||||
|
process.on("unhandledRejection", (err) => {
|
||||||
|
console.error(err);
|
||||||
|
shutdown(1);
|
||||||
|
});
|
||||||
2
dist/functions/server/full-rebuild.js
vendored
2
dist/functions/server/full-rebuild.js
vendored
@ -1,5 +1,6 @@
|
|||||||
import { log } from "../../utils/log";
|
import { log } from "../../utils/log";
|
||||||
import allPagesESBuildContextBundler from "../bundler/all-pages-esbuild-context-bundler";
|
import allPagesESBuildContextBundler from "../bundler/all-pages-esbuild-context-bundler";
|
||||||
|
import pagesSSRBundler from "../bundler/pages-ssr-bundler";
|
||||||
import serverPostBuildFn from "./server-post-build-fn";
|
import serverPostBuildFn from "./server-post-build-fn";
|
||||||
import watcherEsbuildCTX from "./watcher-esbuild-ctx";
|
import watcherEsbuildCTX from "./watcher-esbuild-ctx";
|
||||||
export default async function fullRebuild(params) {
|
export default async function fullRebuild(params) {
|
||||||
@ -14,6 +15,7 @@ export default async function fullRebuild(params) {
|
|||||||
global.BUNDLER_CTX = undefined;
|
global.BUNDLER_CTX = undefined;
|
||||||
await global.SSR_BUNDLER_CTX?.dispose();
|
await global.SSR_BUNDLER_CTX?.dispose();
|
||||||
global.SSR_BUNDLER_CTX = undefined;
|
global.SSR_BUNDLER_CTX = undefined;
|
||||||
|
await pagesSSRBundler();
|
||||||
allPagesESBuildContextBundler({
|
allPagesESBuildContextBundler({
|
||||||
post_build_fn: () => {
|
post_build_fn: () => {
|
||||||
serverPostBuildFn();
|
serverPostBuildFn();
|
||||||
|
|||||||
6
dist/functions/server/watcher-esbuild-ctx.js
vendored
6
dist/functions/server/watcher-esbuild-ctx.js
vendored
@ -5,7 +5,7 @@ import fullRebuild from "./full-rebuild";
|
|||||||
import { AppData } from "../../data/app-data";
|
import { AppData } from "../../data/app-data";
|
||||||
import checkExcludedPatterns from "../../utils/check-excluded-patterns";
|
import checkExcludedPatterns from "../../utils/check-excluded-patterns";
|
||||||
import pagesSSRBundler from "../bundler/pages-ssr-bundler";
|
import pagesSSRBundler from "../bundler/pages-ssr-bundler";
|
||||||
const { ROOT_DIR } = grabDirNames();
|
const { ROOT_DIR, BUNX_BUNDLER_ERROR_EXIT_FILE } = grabDirNames();
|
||||||
export default async function watcherEsbuildCTX() {
|
export default async function watcherEsbuildCTX() {
|
||||||
const pages_src_watcher = watch(ROOT_DIR, {
|
const pages_src_watcher = watch(ROOT_DIR, {
|
||||||
recursive: true,
|
recursive: true,
|
||||||
@ -13,6 +13,10 @@ export default async function watcherEsbuildCTX() {
|
|||||||
}, async (event, filename) => {
|
}, async (event, filename) => {
|
||||||
if (!filename)
|
if (!filename)
|
||||||
return;
|
return;
|
||||||
|
if (existsSync(BUNX_BUNDLER_ERROR_EXIT_FILE)) {
|
||||||
|
await fullRebuild();
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (filename.match(/^\.\w+/)) {
|
if (filename.match(/^\.\w+/)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
4
dist/functions/write-error-file.d.ts
vendored
Normal file
4
dist/functions/write-error-file.d.ts
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
export default function writeErrorFile({ exitCode, error, }: {
|
||||||
|
error?: Bun.ErrorLike;
|
||||||
|
exitCode: number | null;
|
||||||
|
}): void;
|
||||||
21
dist/functions/write-error-file.js
vendored
Normal file
21
dist/functions/write-error-file.js
vendored
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
import path from "path";
|
||||||
|
import { mkdirSync, writeFileSync } from "fs";
|
||||||
|
import grabDirNames from "../utils/grab-dir-names";
|
||||||
|
const { BUNX_BUNDLER_ERROR_EXIT_FILE } = grabDirNames();
|
||||||
|
export default function writeErrorFile({ exitCode, error, }) {
|
||||||
|
let txt = ``;
|
||||||
|
txt += `Bunext Error\n`;
|
||||||
|
txt += `============================================\n`;
|
||||||
|
txt += `ERROR: ${error?.message}\n`;
|
||||||
|
txt += `EXIT_CODE: ${exitCode || 0}\n`;
|
||||||
|
txt += `CALL_STACK: ${error?.stack}\n`;
|
||||||
|
mkdirSync(path.dirname(BUNX_BUNDLER_ERROR_EXIT_FILE), { recursive: true });
|
||||||
|
writeFileSync(BUNX_BUNDLER_ERROR_EXIT_FILE, txt);
|
||||||
|
}
|
||||||
|
// log.info("Running development server ...");
|
||||||
|
// try {
|
||||||
|
// rmSync(HYDRATION_DST_DIR, { recursive: true });
|
||||||
|
// rmSync(BUNX_CWD_PAGES_REWRITE_DIR, { recursive: true });
|
||||||
|
// } catch (error) {}
|
||||||
|
// await bunextInit();
|
||||||
|
// await startServer();
|
||||||
4
dist/types/index.d.ts
vendored
4
dist/types/index.d.ts
vendored
@ -53,6 +53,7 @@ export type BunextConfig = {
|
|||||||
* from the router
|
* from the router
|
||||||
*/
|
*/
|
||||||
pages_exclude_patterns?: RegExp[];
|
pages_exclude_patterns?: RegExp[];
|
||||||
|
max_logs?: number;
|
||||||
};
|
};
|
||||||
export type BunextConfigMiddlewareParams = {
|
export type BunextConfigMiddlewareParams = {
|
||||||
req: Request;
|
req: Request;
|
||||||
@ -314,3 +315,6 @@ export type BunextAPIRouteHandlerObjectReturn<T> = Response | (T & Pick<BunextAP
|
|||||||
export type BunextAPIRouteHandler<T extends BunextAPIRouteJSONRes = {
|
export type BunextAPIRouteHandler<T extends BunextAPIRouteJSONRes = {
|
||||||
[k: string]: any;
|
[k: string]: any;
|
||||||
}> = (params: BunxRouteParams) => Promise<BunextAPIRouteHandlerObjectReturn<T>> | Response | BunextAPIRouteHandlerObjectReturn<T>;
|
}> = (params: BunxRouteParams) => Promise<BunextAPIRouteHandlerObjectReturn<T>> | Response | BunextAPIRouteHandlerObjectReturn<T>;
|
||||||
|
export type BunSpawnOptions = Bun.SpawnOptions.SpawnOptions<"inherit", "inherit", "inherit"> & {
|
||||||
|
cmd: string[];
|
||||||
|
};
|
||||||
|
|||||||
3
dist/utils/grab-dir-names.d.ts
vendored
3
dist/utils/grab-dir-names.d.ts
vendored
@ -23,4 +23,7 @@ export default function grabDirNames(): {
|
|||||||
HYDRATION_DST_DIR_MAP_JSON_FILE_NAME: string;
|
HYDRATION_DST_DIR_MAP_JSON_FILE_NAME: string;
|
||||||
BUNEXT_VENDOR_DIR: string;
|
BUNEXT_VENDOR_DIR: string;
|
||||||
BUNEXT_PUBLIC_DIR: string;
|
BUNEXT_PUBLIC_DIR: string;
|
||||||
|
BUNX_BUNDLER_ERROR_EXIT_FILE: string;
|
||||||
|
BUNX_ERROR_LOGS_DIR: string;
|
||||||
|
BUNX_LOGS_DIR: string;
|
||||||
};
|
};
|
||||||
|
|||||||
148
dist/utils/grab-dir-names.js
vendored
148
dist/utils/grab-dir-names.js
vendored
@ -10,7 +10,10 @@ export default function grabDirNames() {
|
|||||||
const BUNX_CWD_MODULE_CACHE_DIR = path.resolve(BUNX_CWD_DIR, "module-cache");
|
const BUNX_CWD_MODULE_CACHE_DIR = path.resolve(BUNX_CWD_DIR, "module-cache");
|
||||||
const BUNX_CWD_PAGES_REWRITE_DIR = path.resolve(BUNX_CWD_DIR, "pages");
|
const BUNX_CWD_PAGES_REWRITE_DIR = path.resolve(BUNX_CWD_DIR, "pages");
|
||||||
const BUNX_TMP_DIR = path.resolve(BUNX_CWD_DIR, ".tmp");
|
const BUNX_TMP_DIR = path.resolve(BUNX_CWD_DIR, ".tmp");
|
||||||
|
const BUNX_BUNDLER_ERROR_EXIT_FILE = path.resolve(BUNX_TMP_DIR, "BUNDLER_EXIT.txt");
|
||||||
const BUNX_HYDRATION_SRC_DIR = path.resolve(BUNX_CWD_DIR, "client", "hydration-src");
|
const BUNX_HYDRATION_SRC_DIR = path.resolve(BUNX_CWD_DIR, "client", "hydration-src");
|
||||||
|
const BUNX_LOGS_DIR = path.resolve(BUNX_CWD_DIR, "logs");
|
||||||
|
const BUNX_ERROR_LOGS_DIR = path.resolve(BUNX_LOGS_DIR, "error");
|
||||||
const BUNEXT_PUBLIC_DIR = path.join(BUNX_CWD_DIR, "public");
|
const BUNEXT_PUBLIC_DIR = path.join(BUNX_CWD_DIR, "public");
|
||||||
const HYDRATION_DST_DIR = path.join(BUNEXT_PUBLIC_DIR, "pages");
|
const HYDRATION_DST_DIR = path.join(BUNEXT_PUBLIC_DIR, "pages");
|
||||||
const BUNEXT_VENDOR_DIR = path.join(BUNEXT_PUBLIC_DIR, "vendor");
|
const BUNEXT_VENDOR_DIR = path.join(BUNEXT_PUBLIC_DIR, "vendor");
|
||||||
@ -24,64 +27,6 @@ export default function grabDirNames() {
|
|||||||
const BUNX_ROOT_500_PRESET_COMPONENT = path.join(BUNX_ROOT_PRESETS_DIR, `${BUNX_ROOT_500_FILE_NAME}.tsx`);
|
const BUNX_ROOT_500_PRESET_COMPONENT = path.join(BUNX_ROOT_PRESETS_DIR, `${BUNX_ROOT_500_FILE_NAME}.tsx`);
|
||||||
const BUNX_ROOT_404_FILE_NAME = `not-found`;
|
const BUNX_ROOT_404_FILE_NAME = `not-found`;
|
||||||
const BUNX_ROOT_404_PRESET_COMPONENT = path.join(BUNX_ROOT_PRESETS_DIR, `${BUNX_ROOT_404_FILE_NAME}.tsx`);
|
const BUNX_ROOT_404_PRESET_COMPONENT = path.join(BUNX_ROOT_PRESETS_DIR, `${BUNX_ROOT_404_FILE_NAME}.tsx`);
|
||||||
// const NODE_MODULES_DIR = path.resolve(
|
|
||||||
// existsSync(path.join(BUNX_ROOT_DIR, "source.md"))
|
|
||||||
// ? BUNX_ROOT_DIR
|
|
||||||
// : ROOT_DIR,
|
|
||||||
// "node_modules",
|
|
||||||
// );
|
|
||||||
// const REACT_MODULE_DIR = path.join(NODE_MODULES_DIR, "react");
|
|
||||||
// const REACT_DOM_MODULE_DIR = path.join(NODE_MODULES_DIR, "react-dom");
|
|
||||||
// const REACT_PRODUCTION_MODULE = path.join(
|
|
||||||
// REACT_MODULE_DIR,
|
|
||||||
// "cjs",
|
|
||||||
// "react.production.js",
|
|
||||||
// );
|
|
||||||
// const REACT_DEVELOPMENT_MODULE = path.join(
|
|
||||||
// REACT_MODULE_DIR,
|
|
||||||
// "cjs",
|
|
||||||
// "react.development.js",
|
|
||||||
// );
|
|
||||||
// const REACT_JSX_RUNTIME_PRODUCTION_MODULE = path.join(
|
|
||||||
// REACT_MODULE_DIR,
|
|
||||||
// "cjs",
|
|
||||||
// "react-jsx-runtime.production.js",
|
|
||||||
// );
|
|
||||||
// const REACT_JSX_RUNTIME_DEVELOPMENT_MODULE = path.join(
|
|
||||||
// REACT_MODULE_DIR,
|
|
||||||
// "cjs",
|
|
||||||
// "react-jsx-runtime.development.js",
|
|
||||||
// );
|
|
||||||
// const REACT_JSX_DEVELOPMENT_RUNTIME_PRODUCTION_MODULE = path.join(
|
|
||||||
// REACT_MODULE_DIR,
|
|
||||||
// "cjs",
|
|
||||||
// "react-jsx-dev-runtime.production.js",
|
|
||||||
// );
|
|
||||||
// const REACT_JSX_DEVELOPMENT_RUNTIME_DEVELOPMENT_MODULE = path.join(
|
|
||||||
// REACT_MODULE_DIR,
|
|
||||||
// "cjs",
|
|
||||||
// "react-jsx-dev-runtime.development.js",
|
|
||||||
// );
|
|
||||||
// const REACT_DOM_PRODUCTION_MODULE = path.join(
|
|
||||||
// REACT_DOM_MODULE_DIR,
|
|
||||||
// "cjs",
|
|
||||||
// "react-dom.production.js",
|
|
||||||
// );
|
|
||||||
// const REACT_DOM_DEVELOPMENT_MODULE = path.join(
|
|
||||||
// REACT_DOM_MODULE_DIR,
|
|
||||||
// "cjs",
|
|
||||||
// "react-dom.development.js",
|
|
||||||
// );
|
|
||||||
// const REACT_DOM_CLIENT_PRODUCTION_MODULE = path.join(
|
|
||||||
// REACT_DOM_MODULE_DIR,
|
|
||||||
// "cjs",
|
|
||||||
// "react-dom-client.production.js",
|
|
||||||
// );
|
|
||||||
// const REACT_DOM_CLIENT_DEVELOPMENT_MODULE = path.join(
|
|
||||||
// REACT_DOM_MODULE_DIR,
|
|
||||||
// "cjs",
|
|
||||||
// "react-dom-client.development.js",
|
|
||||||
// );
|
|
||||||
return {
|
return {
|
||||||
ROOT_DIR,
|
ROOT_DIR,
|
||||||
SRC_DIR,
|
SRC_DIR,
|
||||||
@ -107,18 +52,79 @@ export default function grabDirNames() {
|
|||||||
HYDRATION_DST_DIR_MAP_JSON_FILE_NAME,
|
HYDRATION_DST_DIR_MAP_JSON_FILE_NAME,
|
||||||
BUNEXT_VENDOR_DIR,
|
BUNEXT_VENDOR_DIR,
|
||||||
BUNEXT_PUBLIC_DIR,
|
BUNEXT_PUBLIC_DIR,
|
||||||
// NODE_MODULES_DIR,
|
BUNX_BUNDLER_ERROR_EXIT_FILE,
|
||||||
// REACT_MODULE_DIR,
|
BUNX_ERROR_LOGS_DIR,
|
||||||
// REACT_DOM_MODULE_DIR,
|
BUNX_LOGS_DIR,
|
||||||
// REACT_PRODUCTION_MODULE,
|
|
||||||
// REACT_DEVELOPMENT_MODULE,
|
|
||||||
// REACT_JSX_RUNTIME_PRODUCTION_MODULE,
|
|
||||||
// REACT_JSX_RUNTIME_DEVELOPMENT_MODULE,
|
|
||||||
// REACT_JSX_DEVELOPMENT_RUNTIME_PRODUCTION_MODULE,
|
|
||||||
// REACT_JSX_DEVELOPMENT_RUNTIME_DEVELOPMENT_MODULE,
|
|
||||||
// REACT_DOM_PRODUCTION_MODULE,
|
|
||||||
// REACT_DOM_DEVELOPMENT_MODULE,
|
|
||||||
// REACT_DOM_CLIENT_PRODUCTION_MODULE,
|
|
||||||
// REACT_DOM_CLIENT_DEVELOPMENT_MODULE,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
// const NODE_MODULES_DIR = path.resolve(
|
||||||
|
// existsSync(path.join(BUNX_ROOT_DIR, "source.md"))
|
||||||
|
// ? BUNX_ROOT_DIR
|
||||||
|
// : ROOT_DIR,
|
||||||
|
// "node_modules",
|
||||||
|
// );
|
||||||
|
// const REACT_MODULE_DIR = path.join(NODE_MODULES_DIR, "react");
|
||||||
|
// const REACT_DOM_MODULE_DIR = path.join(NODE_MODULES_DIR, "react-dom");
|
||||||
|
// const REACT_PRODUCTION_MODULE = path.join(
|
||||||
|
// REACT_MODULE_DIR,
|
||||||
|
// "cjs",
|
||||||
|
// "react.production.js",
|
||||||
|
// );
|
||||||
|
// const REACT_DEVELOPMENT_MODULE = path.join(
|
||||||
|
// REACT_MODULE_DIR,
|
||||||
|
// "cjs",
|
||||||
|
// "react.development.js",
|
||||||
|
// );
|
||||||
|
// const REACT_JSX_RUNTIME_PRODUCTION_MODULE = path.join(
|
||||||
|
// REACT_MODULE_DIR,
|
||||||
|
// "cjs",
|
||||||
|
// "react-jsx-runtime.production.js",
|
||||||
|
// );
|
||||||
|
// const REACT_JSX_RUNTIME_DEVELOPMENT_MODULE = path.join(
|
||||||
|
// REACT_MODULE_DIR,
|
||||||
|
// "cjs",
|
||||||
|
// "react-jsx-runtime.development.js",
|
||||||
|
// );
|
||||||
|
// const REACT_JSX_DEVELOPMENT_RUNTIME_PRODUCTION_MODULE = path.join(
|
||||||
|
// REACT_MODULE_DIR,
|
||||||
|
// "cjs",
|
||||||
|
// "react-jsx-dev-runtime.production.js",
|
||||||
|
// );
|
||||||
|
// const REACT_JSX_DEVELOPMENT_RUNTIME_DEVELOPMENT_MODULE = path.join(
|
||||||
|
// REACT_MODULE_DIR,
|
||||||
|
// "cjs",
|
||||||
|
// "react-jsx-dev-runtime.development.js",
|
||||||
|
// );
|
||||||
|
// const REACT_DOM_PRODUCTION_MODULE = path.join(
|
||||||
|
// REACT_DOM_MODULE_DIR,
|
||||||
|
// "cjs",
|
||||||
|
// "react-dom.production.js",
|
||||||
|
// );
|
||||||
|
// const REACT_DOM_DEVELOPMENT_MODULE = path.join(
|
||||||
|
// REACT_DOM_MODULE_DIR,
|
||||||
|
// "cjs",
|
||||||
|
// "react-dom.development.js",
|
||||||
|
// );
|
||||||
|
// const REACT_DOM_CLIENT_PRODUCTION_MODULE = path.join(
|
||||||
|
// REACT_DOM_MODULE_DIR,
|
||||||
|
// "cjs",
|
||||||
|
// "react-dom-client.production.js",
|
||||||
|
// );
|
||||||
|
// const REACT_DOM_CLIENT_DEVELOPMENT_MODULE = path.join(
|
||||||
|
// REACT_DOM_MODULE_DIR,
|
||||||
|
// "cjs",
|
||||||
|
// "react-dom-client.development.js",
|
||||||
|
// );
|
||||||
|
// NODE_MODULES_DIR,
|
||||||
|
// REACT_MODULE_DIR,
|
||||||
|
// REACT_DOM_MODULE_DIR,
|
||||||
|
// REACT_PRODUCTION_MODULE,
|
||||||
|
// REACT_DEVELOPMENT_MODULE,
|
||||||
|
// REACT_JSX_RUNTIME_PRODUCTION_MODULE,
|
||||||
|
// REACT_JSX_RUNTIME_DEVELOPMENT_MODULE,
|
||||||
|
// REACT_JSX_DEVELOPMENT_RUNTIME_PRODUCTION_MODULE,
|
||||||
|
// REACT_JSX_DEVELOPMENT_RUNTIME_DEVELOPMENT_MODULE,
|
||||||
|
// REACT_DOM_PRODUCTION_MODULE,
|
||||||
|
// REACT_DOM_DEVELOPMENT_MODULE,
|
||||||
|
// REACT_DOM_CLIENT_PRODUCTION_MODULE,
|
||||||
|
// REACT_DOM_CLIENT_DEVELOPMENT_MODULE,
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@moduletrace/bunext",
|
"name": "@moduletrace/bunext",
|
||||||
"version": "1.0.81",
|
"version": "1.0.82",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"module": "index.ts",
|
"module": "index.ts",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
18
src/commands/dev/dev-spawn.ts
Normal file
18
src/commands/dev/dev-spawn.ts
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
import startServer from "../../functions/server/start-server";
|
||||||
|
import { log } from "../../utils/log";
|
||||||
|
import bunextInit from "../../functions/bunext-init";
|
||||||
|
import grabDirNames from "../../utils/grab-dir-names";
|
||||||
|
import { rmSync } from "fs";
|
||||||
|
|
||||||
|
const { HYDRATION_DST_DIR, BUNX_CWD_PAGES_REWRITE_DIR } = grabDirNames();
|
||||||
|
|
||||||
|
log.info("Running development server ...");
|
||||||
|
|
||||||
|
try {
|
||||||
|
rmSync(HYDRATION_DST_DIR, { recursive: true });
|
||||||
|
rmSync(BUNX_CWD_PAGES_REWRITE_DIR, { recursive: true });
|
||||||
|
} catch (error) {}
|
||||||
|
|
||||||
|
await bunextInit();
|
||||||
|
|
||||||
|
await startServer();
|
||||||
@ -1,31 +1,36 @@
|
|||||||
import { Command } from "commander";
|
import { Command } from "commander";
|
||||||
import startServer from "../../functions/server/start-server";
|
import path from "path";
|
||||||
import { log } from "../../utils/log";
|
import type { BunSpawnOptions } from "../../types";
|
||||||
import bunextInit from "../../functions/bunext-init";
|
|
||||||
import grabDirNames from "../../utils/grab-dir-names";
|
import grabDirNames from "../../utils/grab-dir-names";
|
||||||
import { rmSync } from "fs";
|
import writeErrorFile from "../../functions/write-error-file";
|
||||||
|
|
||||||
const {
|
|
||||||
HYDRATION_DST_DIR,
|
|
||||||
BUNX_CWD_PAGES_REWRITE_DIR,
|
|
||||||
BUNX_CWD_MODULE_CACHE_DIR,
|
|
||||||
} = grabDirNames();
|
|
||||||
|
|
||||||
export default function () {
|
export default function () {
|
||||||
return new Command("dev")
|
return new Command("dev")
|
||||||
.description("Run development server")
|
.description("Run development server")
|
||||||
.action(async () => {
|
.action(async () => {
|
||||||
process.env.NODE_ENV = "development";
|
await dev();
|
||||||
|
|
||||||
log.info("Running development server ...");
|
|
||||||
|
|
||||||
try {
|
|
||||||
rmSync(HYDRATION_DST_DIR, { recursive: true });
|
|
||||||
rmSync(BUNX_CWD_PAGES_REWRITE_DIR, { recursive: true });
|
|
||||||
} catch (error) {}
|
|
||||||
|
|
||||||
await bunextInit();
|
|
||||||
|
|
||||||
await startServer();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function dev() {
|
||||||
|
const dev_spawn_file = path.resolve(__dirname, "dev-spawn.ts");
|
||||||
|
|
||||||
|
const spawn_options: BunSpawnOptions = {
|
||||||
|
cmd: ["bun", dev_spawn_file],
|
||||||
|
stdio: ["inherit", "inherit", "inherit"],
|
||||||
|
onExit(subprocess, exitCode, signalCode, error) {
|
||||||
|
writeErrorFile({ exitCode, error });
|
||||||
|
},
|
||||||
|
env: {
|
||||||
|
...process.env,
|
||||||
|
NODE_ENV: "development",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
let dev_process = Bun.spawn(spawn_options);
|
||||||
|
|
||||||
|
const exited = await dev_process.exited;
|
||||||
|
if (exited) {
|
||||||
|
return await dev();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -1,17 +1,36 @@
|
|||||||
import { Command } from "commander";
|
import { Command } from "commander";
|
||||||
import startServer from "../../functions/server/start-server";
|
import path from "path";
|
||||||
import { log } from "../../utils/log";
|
import type { BunSpawnOptions } from "../../types";
|
||||||
import bunextInit from "../../functions/bunext-init";
|
import writeErrorFile from "../../functions/write-error-file";
|
||||||
|
|
||||||
export default function () {
|
export default function () {
|
||||||
return new Command("start")
|
return new Command("start")
|
||||||
.description("Start production server")
|
.description("Start production server")
|
||||||
.action(async () => {
|
.action(async () => {
|
||||||
process.env.NODE_ENV = "production";
|
await start();
|
||||||
log.info("Starting production server ...");
|
|
||||||
|
|
||||||
await bunextInit();
|
|
||||||
|
|
||||||
await startServer();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function start() {
|
||||||
|
const dev_spawn_file = path.resolve(__dirname, "prod-spawn.ts");
|
||||||
|
|
||||||
|
const spawn_options: BunSpawnOptions = {
|
||||||
|
cmd: ["bun", dev_spawn_file],
|
||||||
|
stdio: ["inherit", "inherit", "inherit"],
|
||||||
|
onExit(subprocess, exitCode, signalCode, error) {
|
||||||
|
writeErrorFile({ exitCode, error });
|
||||||
|
},
|
||||||
|
env: {
|
||||||
|
...process.env,
|
||||||
|
NODE_ENV: "production",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
let dev_process = Bun.spawn(spawn_options);
|
||||||
|
|
||||||
|
const exited = await dev_process.exited;
|
||||||
|
|
||||||
|
if (exited) {
|
||||||
|
return await start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
9
src/commands/start/prod-spawn.ts
Normal file
9
src/commands/start/prod-spawn.ts
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import bunextInit from "../../functions/bunext-init";
|
||||||
|
import startServer from "../../functions/server/start-server";
|
||||||
|
import { log } from "../../utils/log";
|
||||||
|
|
||||||
|
log.info("Starting production server ...");
|
||||||
|
|
||||||
|
await bunextInit();
|
||||||
|
|
||||||
|
await startServer();
|
||||||
@ -6,4 +6,5 @@ export const AppData = {
|
|||||||
BunextClientHydrationScriptID: "bunext-client-hydration-script",
|
BunextClientHydrationScriptID: "bunext-client-hydration-script",
|
||||||
BunextTmpFileExt: ".bunext_tmp.tsx",
|
BunextTmpFileExt: ".bunext_tmp.tsx",
|
||||||
BunextHMRRetryRoute: "/.bunext/hmr-retry",
|
BunextHMRRetryRoute: "/.bunext/hmr-retry",
|
||||||
|
DefaultMaxLogs: 50,
|
||||||
} as const;
|
} as const;
|
||||||
|
|||||||
@ -8,8 +8,13 @@ import type { BundlerCTXMap, PageFiles } from "../../types";
|
|||||||
import path from "path";
|
import path from "path";
|
||||||
import virtualFilesPlugin from "./plugins/virtual-files-plugin";
|
import virtualFilesPlugin from "./plugins/virtual-files-plugin";
|
||||||
import esbuildCTXArtifactTracker from "./plugins/esbuild-ctx-artifact-tracker";
|
import esbuildCTXArtifactTracker from "./plugins/esbuild-ctx-artifact-tracker";
|
||||||
|
import { existsSync } from "fs";
|
||||||
|
|
||||||
const { HYDRATION_DST_DIR, BUNX_HYDRATION_SRC_DIR } = grabDirNames();
|
const {
|
||||||
|
HYDRATION_DST_DIR,
|
||||||
|
BUNX_HYDRATION_SRC_DIR,
|
||||||
|
BUNX_BUNDLER_ERROR_EXIT_FILE,
|
||||||
|
} = grabDirNames();
|
||||||
|
|
||||||
type Params = {
|
type Params = {
|
||||||
post_build_fn?: (params: {
|
post_build_fn?: (params: {
|
||||||
@ -19,6 +24,10 @@ type Params = {
|
|||||||
|
|
||||||
export default async function allPagesESBuildContextBundler(params?: Params) {
|
export default async function allPagesESBuildContextBundler(params?: Params) {
|
||||||
try {
|
try {
|
||||||
|
const did_process_exit_because_of_bundler_error = existsSync(
|
||||||
|
BUNX_BUNDLER_ERROR_EXIT_FILE,
|
||||||
|
);
|
||||||
|
|
||||||
const pages = grabAllPages({ exclude_api: true });
|
const pages = grabAllPages({ exclude_api: true });
|
||||||
|
|
||||||
global.PAGE_FILES = pages;
|
global.PAGE_FILES = pages;
|
||||||
@ -83,6 +92,9 @@ export default async function allPagesESBuildContextBundler(params?: Params) {
|
|||||||
"react/jsx-runtime",
|
"react/jsx-runtime",
|
||||||
"react/jsx-dev-runtime",
|
"react/jsx-dev-runtime",
|
||||||
],
|
],
|
||||||
|
logLevel: did_process_exit_because_of_bundler_error
|
||||||
|
? "silent"
|
||||||
|
: undefined,
|
||||||
});
|
});
|
||||||
|
|
||||||
await global.BUNDLER_CTX.rebuild();
|
await global.BUNDLER_CTX.rebuild();
|
||||||
|
|||||||
@ -5,10 +5,17 @@ import grabArtifactsFromBundledResults from "../grab-artifacts-from-bundled-resu
|
|||||||
import buildOnstartErrorHandler from "../build-on-start-error-handler";
|
import buildOnstartErrorHandler from "../build-on-start-error-handler";
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
import pagesSSRBundler from "../pages-ssr-bundler";
|
import pagesSSRBundler from "../pages-ssr-bundler";
|
||||||
|
import grabDirNames from "../../../utils/grab-dir-names";
|
||||||
|
import { cpSync, existsSync, mkdirSync, rmSync } from "fs";
|
||||||
|
import fullRebuild from "../../server/full-rebuild";
|
||||||
|
import path from "path";
|
||||||
|
import cleanupLogsDirs from "../../cleanup-logs-dir";
|
||||||
|
|
||||||
|
const { BUNX_BUNDLER_ERROR_EXIT_FILE, BUNX_ERROR_LOGS_DIR } = grabDirNames();
|
||||||
|
|
||||||
let build_start = 0;
|
let build_start = 0;
|
||||||
let build_starts = 0;
|
let build_starts = 0;
|
||||||
const MAX_BUILD_STARTS = 5;
|
const MAX_BUILD_STARTS = 2;
|
||||||
|
|
||||||
type Params = {
|
type Params = {
|
||||||
entryToPage: Map<
|
entryToPage: Map<
|
||||||
@ -31,8 +38,16 @@ export default function esbuildCTXArtifactTracker({
|
|||||||
build_starts++;
|
build_starts++;
|
||||||
build_start = performance.now();
|
build_start = performance.now();
|
||||||
|
|
||||||
if (build_starts == MAX_BUILD_STARTS) {
|
const does_error_file_exist = existsSync(
|
||||||
|
BUNX_BUNDLER_ERROR_EXIT_FILE,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (
|
||||||
|
build_starts == MAX_BUILD_STARTS &&
|
||||||
|
!does_error_file_exist
|
||||||
|
) {
|
||||||
await buildOnstartErrorHandler();
|
await buildOnstartErrorHandler();
|
||||||
|
process.exit(1);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -69,7 +84,22 @@ export default function esbuildCTXArtifactTracker({
|
|||||||
|
|
||||||
build_starts = 0;
|
build_starts = 0;
|
||||||
|
|
||||||
pagesSSRBundler();
|
const does_error_file_exist = existsSync(
|
||||||
|
BUNX_BUNDLER_ERROR_EXIT_FILE,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (does_error_file_exist) {
|
||||||
|
mkdirSync(BUNX_ERROR_LOGS_DIR, { recursive: true });
|
||||||
|
cpSync(
|
||||||
|
BUNX_BUNDLER_ERROR_EXIT_FILE,
|
||||||
|
path.join(BUNX_ERROR_LOGS_DIR, `${Date.now()}.log`),
|
||||||
|
);
|
||||||
|
rmSync(BUNX_BUNDLER_ERROR_EXIT_FILE, { force: true });
|
||||||
|
cleanupLogsDirs();
|
||||||
|
fullRebuild();
|
||||||
|
} else {
|
||||||
|
pagesSSRBundler();
|
||||||
|
}
|
||||||
|
|
||||||
// if (global.SSR_BUNDLER_CTX) {
|
// if (global.SSR_BUNDLER_CTX) {
|
||||||
// global.SSR_BUNDLER_CTX.rebuild();
|
// global.SSR_BUNDLER_CTX.rebuild();
|
||||||
|
|||||||
@ -102,9 +102,9 @@ export default async function bunextInit() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
process.on("exit", (code) => {
|
// process.on("exit", (code) => {
|
||||||
Bun.spawn([process.execPath, ...process.argv.slice(1)], {
|
// Bun.spawn([process.execPath, ...process.argv.slice(1)], {
|
||||||
stdio: ["inherit", "inherit", "inherit"],
|
// stdio: ["inherit", "inherit", "inherit"],
|
||||||
env: process.env,
|
// env: process.env,
|
||||||
});
|
// });
|
||||||
});
|
// });
|
||||||
|
|||||||
63
src/functions/cleanup-logs-dir.ts
Normal file
63
src/functions/cleanup-logs-dir.ts
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
import path from "path";
|
||||||
|
import { mkdirSync, readdirSync, rmSync, statSync, writeFileSync } from "fs";
|
||||||
|
import grabDirNames from "../utils/grab-dir-names";
|
||||||
|
import grabConstants from "../utils/grab-constants";
|
||||||
|
import { AppData } from "../data/app-data";
|
||||||
|
|
||||||
|
const { BUNX_LOGS_DIR } = grabDirNames();
|
||||||
|
|
||||||
|
export default function cleanupLogsDirs() {
|
||||||
|
const logs_dirs = readdirSync(BUNX_LOGS_DIR);
|
||||||
|
const { config } = grabConstants();
|
||||||
|
|
||||||
|
const MAX_LOGS = config.max_logs || AppData["DefaultMaxLogs"];
|
||||||
|
|
||||||
|
for (let i = 0; i < logs_dirs.length; i++) {
|
||||||
|
const dir = logs_dirs[i];
|
||||||
|
const full_path = path.join(BUNX_LOGS_DIR, dir);
|
||||||
|
|
||||||
|
const path_stats = statSync(full_path);
|
||||||
|
|
||||||
|
if (!path_stats.isDirectory()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const sub_dir_files = readdirSync(full_path).sort((a, b) => {
|
||||||
|
const timestamp_a = Number(a.split(".")[0]);
|
||||||
|
const timestamp_b = Number(b.split(".")[0]);
|
||||||
|
|
||||||
|
if (timestamp_a > timestamp_b) return 1;
|
||||||
|
return -1;
|
||||||
|
});
|
||||||
|
|
||||||
|
for (let j = 0; j < sub_dir_files.length; j++) {
|
||||||
|
const sub_dir_file = sub_dir_files[j];
|
||||||
|
const sub_dir_file_full_path = path.join(full_path, sub_dir_file);
|
||||||
|
|
||||||
|
const sub_dir_file_Stats = statSync(sub_dir_file_full_path);
|
||||||
|
|
||||||
|
if (!sub_dir_file_Stats.isFile()) {
|
||||||
|
rmSync(sub_dir_file_full_path, {
|
||||||
|
force: true,
|
||||||
|
recursive: true,
|
||||||
|
});
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (j > MAX_LOGS - 1) {
|
||||||
|
rmSync(sub_dir_file_full_path, { force: true });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// log.info("Running development server ...");
|
||||||
|
|
||||||
|
// try {
|
||||||
|
// rmSync(HYDRATION_DST_DIR, { recursive: true });
|
||||||
|
// rmSync(BUNX_CWD_PAGES_REWRITE_DIR, { recursive: true });
|
||||||
|
// } catch (error) {}
|
||||||
|
|
||||||
|
// await bunextInit();
|
||||||
|
|
||||||
|
// await startServer();
|
||||||
53
src/functions/process.ts
Normal file
53
src/functions/process.ts
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
import { spawn } from "bun";
|
||||||
|
|
||||||
|
// Only the "supervisor" respawns. The child sets this env var so it won't respawn itself.
|
||||||
|
const IS_CHILD = process.env.__RESPAWN_CHILD === "1";
|
||||||
|
|
||||||
|
let shuttingDown = false;
|
||||||
|
|
||||||
|
async function cleanup() {
|
||||||
|
// Put real cleanup here: close DB handles, servers, file descriptors, timers, etc.
|
||||||
|
// Must be awaitable — do NOT rely on process.on("exit") for this.
|
||||||
|
}
|
||||||
|
|
||||||
|
function respawn(code: number) {
|
||||||
|
const child = spawn({
|
||||||
|
cmd: [process.execPath, ...process.argv.slice(1)],
|
||||||
|
stdio: ["inherit", "inherit", "inherit"],
|
||||||
|
env: { ...process.env, __RESPAWN_CHILD: "1" },
|
||||||
|
// Detach so the child survives independently and gets its own process group.
|
||||||
|
// Without this, killing the parent's group can take the child with it.
|
||||||
|
});
|
||||||
|
// Let the child live on its own.
|
||||||
|
child.unref?.();
|
||||||
|
}
|
||||||
|
|
||||||
|
async function shutdown(code: number) {
|
||||||
|
if (shuttingDown) return;
|
||||||
|
shuttingDown = true;
|
||||||
|
|
||||||
|
try {
|
||||||
|
await cleanup();
|
||||||
|
} catch (e) {
|
||||||
|
console.error("cleanup failed:", e);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Only the supervisor respawns, and only on abnormal exit.
|
||||||
|
if (!IS_CHILD && code !== 0) {
|
||||||
|
respawn(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
process.exit(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Catch the things that actually fire *before* exit, where async works.
|
||||||
|
process.on("SIGINT", () => shutdown(130));
|
||||||
|
process.on("SIGTERM", () => shutdown(143));
|
||||||
|
process.on("uncaughtException", (err) => {
|
||||||
|
console.error(err);
|
||||||
|
shutdown(1);
|
||||||
|
});
|
||||||
|
process.on("unhandledRejection", (err) => {
|
||||||
|
console.error(err);
|
||||||
|
shutdown(1);
|
||||||
|
});
|
||||||
@ -1,5 +1,6 @@
|
|||||||
import { log } from "../../utils/log";
|
import { log } from "../../utils/log";
|
||||||
import allPagesESBuildContextBundler from "../bundler/all-pages-esbuild-context-bundler";
|
import allPagesESBuildContextBundler from "../bundler/all-pages-esbuild-context-bundler";
|
||||||
|
import pagesSSRBundler from "../bundler/pages-ssr-bundler";
|
||||||
import serverPostBuildFn from "./server-post-build-fn";
|
import serverPostBuildFn from "./server-post-build-fn";
|
||||||
import watcherEsbuildCTX from "./watcher-esbuild-ctx";
|
import watcherEsbuildCTX from "./watcher-esbuild-ctx";
|
||||||
|
|
||||||
@ -21,6 +22,8 @@ export default async function fullRebuild(params?: { msg?: string }) {
|
|||||||
await global.SSR_BUNDLER_CTX?.dispose();
|
await global.SSR_BUNDLER_CTX?.dispose();
|
||||||
global.SSR_BUNDLER_CTX = undefined;
|
global.SSR_BUNDLER_CTX = undefined;
|
||||||
|
|
||||||
|
await pagesSSRBundler();
|
||||||
|
|
||||||
allPagesESBuildContextBundler({
|
allPagesESBuildContextBundler({
|
||||||
post_build_fn: () => {
|
post_build_fn: () => {
|
||||||
serverPostBuildFn();
|
serverPostBuildFn();
|
||||||
|
|||||||
@ -6,7 +6,7 @@ import { AppData } from "../../data/app-data";
|
|||||||
import checkExcludedPatterns from "../../utils/check-excluded-patterns";
|
import checkExcludedPatterns from "../../utils/check-excluded-patterns";
|
||||||
import pagesSSRBundler from "../bundler/pages-ssr-bundler";
|
import pagesSSRBundler from "../bundler/pages-ssr-bundler";
|
||||||
|
|
||||||
const { ROOT_DIR } = grabDirNames();
|
const { ROOT_DIR, BUNX_BUNDLER_ERROR_EXIT_FILE } = grabDirNames();
|
||||||
|
|
||||||
export default async function watcherEsbuildCTX() {
|
export default async function watcherEsbuildCTX() {
|
||||||
const pages_src_watcher = watch(
|
const pages_src_watcher = watch(
|
||||||
@ -18,6 +18,11 @@ export default async function watcherEsbuildCTX() {
|
|||||||
async (event, filename) => {
|
async (event, filename) => {
|
||||||
if (!filename) return;
|
if (!filename) return;
|
||||||
|
|
||||||
|
if (existsSync(BUNX_BUNDLER_ERROR_EXIT_FILE)) {
|
||||||
|
await fullRebuild();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (filename.match(/^\.\w+/)) {
|
if (filename.match(/^\.\w+/)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
34
src/functions/write-error-file.ts
Normal file
34
src/functions/write-error-file.ts
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
import path from "path";
|
||||||
|
import { mkdirSync, writeFileSync } from "fs";
|
||||||
|
import grabDirNames from "../utils/grab-dir-names";
|
||||||
|
|
||||||
|
const { BUNX_BUNDLER_ERROR_EXIT_FILE } = grabDirNames();
|
||||||
|
|
||||||
|
export default function writeErrorFile({
|
||||||
|
exitCode,
|
||||||
|
error,
|
||||||
|
}: {
|
||||||
|
error?: Bun.ErrorLike;
|
||||||
|
exitCode: number | null;
|
||||||
|
}) {
|
||||||
|
let txt = ``;
|
||||||
|
txt += `Bunext Error\n`;
|
||||||
|
txt += `============================================\n`;
|
||||||
|
txt += `ERROR: ${error?.message}\n`;
|
||||||
|
txt += `EXIT_CODE: ${exitCode || 0}\n`;
|
||||||
|
txt += `CALL_STACK: ${error?.stack}\n`;
|
||||||
|
|
||||||
|
mkdirSync(path.dirname(BUNX_BUNDLER_ERROR_EXIT_FILE), { recursive: true });
|
||||||
|
writeFileSync(BUNX_BUNDLER_ERROR_EXIT_FILE, txt);
|
||||||
|
}
|
||||||
|
|
||||||
|
// log.info("Running development server ...");
|
||||||
|
|
||||||
|
// try {
|
||||||
|
// rmSync(HYDRATION_DST_DIR, { recursive: true });
|
||||||
|
// rmSync(BUNX_CWD_PAGES_REWRITE_DIR, { recursive: true });
|
||||||
|
// } catch (error) {}
|
||||||
|
|
||||||
|
// await bunextInit();
|
||||||
|
|
||||||
|
// await startServer();
|
||||||
@ -70,6 +70,7 @@ export type BunextConfig = {
|
|||||||
* from the router
|
* from the router
|
||||||
*/
|
*/
|
||||||
pages_exclude_patterns?: RegExp[];
|
pages_exclude_patterns?: RegExp[];
|
||||||
|
max_logs?: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type BunextConfigMiddlewareParams = {
|
export type BunextConfigMiddlewareParams = {
|
||||||
@ -377,3 +378,11 @@ export type BunextAPIRouteHandler<
|
|||||||
| Promise<BunextAPIRouteHandlerObjectReturn<T>>
|
| Promise<BunextAPIRouteHandlerObjectReturn<T>>
|
||||||
| Response
|
| Response
|
||||||
| BunextAPIRouteHandlerObjectReturn<T>;
|
| BunextAPIRouteHandlerObjectReturn<T>;
|
||||||
|
|
||||||
|
export type BunSpawnOptions = Bun.SpawnOptions.SpawnOptions<
|
||||||
|
"inherit",
|
||||||
|
"inherit",
|
||||||
|
"inherit"
|
||||||
|
> & {
|
||||||
|
cmd: string[];
|
||||||
|
};
|
||||||
|
|||||||
@ -15,11 +15,17 @@ export default function grabDirNames() {
|
|||||||
);
|
);
|
||||||
const BUNX_CWD_PAGES_REWRITE_DIR = path.resolve(BUNX_CWD_DIR, "pages");
|
const BUNX_CWD_PAGES_REWRITE_DIR = path.resolve(BUNX_CWD_DIR, "pages");
|
||||||
const BUNX_TMP_DIR = path.resolve(BUNX_CWD_DIR, ".tmp");
|
const BUNX_TMP_DIR = path.resolve(BUNX_CWD_DIR, ".tmp");
|
||||||
|
const BUNX_BUNDLER_ERROR_EXIT_FILE = path.resolve(
|
||||||
|
BUNX_TMP_DIR,
|
||||||
|
"BUNDLER_EXIT.txt",
|
||||||
|
);
|
||||||
const BUNX_HYDRATION_SRC_DIR = path.resolve(
|
const BUNX_HYDRATION_SRC_DIR = path.resolve(
|
||||||
BUNX_CWD_DIR,
|
BUNX_CWD_DIR,
|
||||||
"client",
|
"client",
|
||||||
"hydration-src",
|
"hydration-src",
|
||||||
);
|
);
|
||||||
|
const BUNX_LOGS_DIR = path.resolve(BUNX_CWD_DIR, "logs");
|
||||||
|
const BUNX_ERROR_LOGS_DIR = path.resolve(BUNX_LOGS_DIR, "error");
|
||||||
|
|
||||||
const BUNEXT_PUBLIC_DIR = path.join(BUNX_CWD_DIR, "public");
|
const BUNEXT_PUBLIC_DIR = path.join(BUNX_CWD_DIR, "public");
|
||||||
const HYDRATION_DST_DIR = path.join(BUNEXT_PUBLIC_DIR, "pages");
|
const HYDRATION_DST_DIR = path.join(BUNEXT_PUBLIC_DIR, "pages");
|
||||||
@ -46,71 +52,6 @@ export default function grabDirNames() {
|
|||||||
`${BUNX_ROOT_404_FILE_NAME}.tsx`,
|
`${BUNX_ROOT_404_FILE_NAME}.tsx`,
|
||||||
);
|
);
|
||||||
|
|
||||||
// const NODE_MODULES_DIR = path.resolve(
|
|
||||||
// existsSync(path.join(BUNX_ROOT_DIR, "source.md"))
|
|
||||||
// ? BUNX_ROOT_DIR
|
|
||||||
// : ROOT_DIR,
|
|
||||||
// "node_modules",
|
|
||||||
// );
|
|
||||||
|
|
||||||
// const REACT_MODULE_DIR = path.join(NODE_MODULES_DIR, "react");
|
|
||||||
// const REACT_DOM_MODULE_DIR = path.join(NODE_MODULES_DIR, "react-dom");
|
|
||||||
|
|
||||||
// const REACT_PRODUCTION_MODULE = path.join(
|
|
||||||
// REACT_MODULE_DIR,
|
|
||||||
// "cjs",
|
|
||||||
// "react.production.js",
|
|
||||||
// );
|
|
||||||
// const REACT_DEVELOPMENT_MODULE = path.join(
|
|
||||||
// REACT_MODULE_DIR,
|
|
||||||
// "cjs",
|
|
||||||
// "react.development.js",
|
|
||||||
// );
|
|
||||||
|
|
||||||
// const REACT_JSX_RUNTIME_PRODUCTION_MODULE = path.join(
|
|
||||||
// REACT_MODULE_DIR,
|
|
||||||
// "cjs",
|
|
||||||
// "react-jsx-runtime.production.js",
|
|
||||||
// );
|
|
||||||
// const REACT_JSX_RUNTIME_DEVELOPMENT_MODULE = path.join(
|
|
||||||
// REACT_MODULE_DIR,
|
|
||||||
// "cjs",
|
|
||||||
// "react-jsx-runtime.development.js",
|
|
||||||
// );
|
|
||||||
|
|
||||||
// const REACT_JSX_DEVELOPMENT_RUNTIME_PRODUCTION_MODULE = path.join(
|
|
||||||
// REACT_MODULE_DIR,
|
|
||||||
// "cjs",
|
|
||||||
// "react-jsx-dev-runtime.production.js",
|
|
||||||
// );
|
|
||||||
// const REACT_JSX_DEVELOPMENT_RUNTIME_DEVELOPMENT_MODULE = path.join(
|
|
||||||
// REACT_MODULE_DIR,
|
|
||||||
// "cjs",
|
|
||||||
// "react-jsx-dev-runtime.development.js",
|
|
||||||
// );
|
|
||||||
|
|
||||||
// const REACT_DOM_PRODUCTION_MODULE = path.join(
|
|
||||||
// REACT_DOM_MODULE_DIR,
|
|
||||||
// "cjs",
|
|
||||||
// "react-dom.production.js",
|
|
||||||
// );
|
|
||||||
// const REACT_DOM_DEVELOPMENT_MODULE = path.join(
|
|
||||||
// REACT_DOM_MODULE_DIR,
|
|
||||||
// "cjs",
|
|
||||||
// "react-dom.development.js",
|
|
||||||
// );
|
|
||||||
|
|
||||||
// const REACT_DOM_CLIENT_PRODUCTION_MODULE = path.join(
|
|
||||||
// REACT_DOM_MODULE_DIR,
|
|
||||||
// "cjs",
|
|
||||||
// "react-dom-client.production.js",
|
|
||||||
// );
|
|
||||||
// const REACT_DOM_CLIENT_DEVELOPMENT_MODULE = path.join(
|
|
||||||
// REACT_DOM_MODULE_DIR,
|
|
||||||
// "cjs",
|
|
||||||
// "react-dom-client.development.js",
|
|
||||||
// );
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
ROOT_DIR,
|
ROOT_DIR,
|
||||||
SRC_DIR,
|
SRC_DIR,
|
||||||
@ -136,18 +77,87 @@ export default function grabDirNames() {
|
|||||||
HYDRATION_DST_DIR_MAP_JSON_FILE_NAME,
|
HYDRATION_DST_DIR_MAP_JSON_FILE_NAME,
|
||||||
BUNEXT_VENDOR_DIR,
|
BUNEXT_VENDOR_DIR,
|
||||||
BUNEXT_PUBLIC_DIR,
|
BUNEXT_PUBLIC_DIR,
|
||||||
// NODE_MODULES_DIR,
|
BUNX_BUNDLER_ERROR_EXIT_FILE,
|
||||||
// REACT_MODULE_DIR,
|
BUNX_ERROR_LOGS_DIR,
|
||||||
// REACT_DOM_MODULE_DIR,
|
BUNX_LOGS_DIR,
|
||||||
// REACT_PRODUCTION_MODULE,
|
|
||||||
// REACT_DEVELOPMENT_MODULE,
|
|
||||||
// REACT_JSX_RUNTIME_PRODUCTION_MODULE,
|
|
||||||
// REACT_JSX_RUNTIME_DEVELOPMENT_MODULE,
|
|
||||||
// REACT_JSX_DEVELOPMENT_RUNTIME_PRODUCTION_MODULE,
|
|
||||||
// REACT_JSX_DEVELOPMENT_RUNTIME_DEVELOPMENT_MODULE,
|
|
||||||
// REACT_DOM_PRODUCTION_MODULE,
|
|
||||||
// REACT_DOM_DEVELOPMENT_MODULE,
|
|
||||||
// REACT_DOM_CLIENT_PRODUCTION_MODULE,
|
|
||||||
// REACT_DOM_CLIENT_DEVELOPMENT_MODULE,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// const NODE_MODULES_DIR = path.resolve(
|
||||||
|
// existsSync(path.join(BUNX_ROOT_DIR, "source.md"))
|
||||||
|
// ? BUNX_ROOT_DIR
|
||||||
|
// : ROOT_DIR,
|
||||||
|
// "node_modules",
|
||||||
|
// );
|
||||||
|
|
||||||
|
// const REACT_MODULE_DIR = path.join(NODE_MODULES_DIR, "react");
|
||||||
|
// const REACT_DOM_MODULE_DIR = path.join(NODE_MODULES_DIR, "react-dom");
|
||||||
|
|
||||||
|
// const REACT_PRODUCTION_MODULE = path.join(
|
||||||
|
// REACT_MODULE_DIR,
|
||||||
|
// "cjs",
|
||||||
|
// "react.production.js",
|
||||||
|
// );
|
||||||
|
// const REACT_DEVELOPMENT_MODULE = path.join(
|
||||||
|
// REACT_MODULE_DIR,
|
||||||
|
// "cjs",
|
||||||
|
// "react.development.js",
|
||||||
|
// );
|
||||||
|
|
||||||
|
// const REACT_JSX_RUNTIME_PRODUCTION_MODULE = path.join(
|
||||||
|
// REACT_MODULE_DIR,
|
||||||
|
// "cjs",
|
||||||
|
// "react-jsx-runtime.production.js",
|
||||||
|
// );
|
||||||
|
// const REACT_JSX_RUNTIME_DEVELOPMENT_MODULE = path.join(
|
||||||
|
// REACT_MODULE_DIR,
|
||||||
|
// "cjs",
|
||||||
|
// "react-jsx-runtime.development.js",
|
||||||
|
// );
|
||||||
|
|
||||||
|
// const REACT_JSX_DEVELOPMENT_RUNTIME_PRODUCTION_MODULE = path.join(
|
||||||
|
// REACT_MODULE_DIR,
|
||||||
|
// "cjs",
|
||||||
|
// "react-jsx-dev-runtime.production.js",
|
||||||
|
// );
|
||||||
|
// const REACT_JSX_DEVELOPMENT_RUNTIME_DEVELOPMENT_MODULE = path.join(
|
||||||
|
// REACT_MODULE_DIR,
|
||||||
|
// "cjs",
|
||||||
|
// "react-jsx-dev-runtime.development.js",
|
||||||
|
// );
|
||||||
|
|
||||||
|
// const REACT_DOM_PRODUCTION_MODULE = path.join(
|
||||||
|
// REACT_DOM_MODULE_DIR,
|
||||||
|
// "cjs",
|
||||||
|
// "react-dom.production.js",
|
||||||
|
// );
|
||||||
|
// const REACT_DOM_DEVELOPMENT_MODULE = path.join(
|
||||||
|
// REACT_DOM_MODULE_DIR,
|
||||||
|
// "cjs",
|
||||||
|
// "react-dom.development.js",
|
||||||
|
// );
|
||||||
|
|
||||||
|
// const REACT_DOM_CLIENT_PRODUCTION_MODULE = path.join(
|
||||||
|
// REACT_DOM_MODULE_DIR,
|
||||||
|
// "cjs",
|
||||||
|
// "react-dom-client.production.js",
|
||||||
|
// );
|
||||||
|
// const REACT_DOM_CLIENT_DEVELOPMENT_MODULE = path.join(
|
||||||
|
// REACT_DOM_MODULE_DIR,
|
||||||
|
// "cjs",
|
||||||
|
// "react-dom-client.development.js",
|
||||||
|
// );
|
||||||
|
|
||||||
|
// NODE_MODULES_DIR,
|
||||||
|
// REACT_MODULE_DIR,
|
||||||
|
// REACT_DOM_MODULE_DIR,
|
||||||
|
// REACT_PRODUCTION_MODULE,
|
||||||
|
// REACT_DEVELOPMENT_MODULE,
|
||||||
|
// REACT_JSX_RUNTIME_PRODUCTION_MODULE,
|
||||||
|
// REACT_JSX_RUNTIME_DEVELOPMENT_MODULE,
|
||||||
|
// REACT_JSX_DEVELOPMENT_RUNTIME_PRODUCTION_MODULE,
|
||||||
|
// REACT_JSX_DEVELOPMENT_RUNTIME_DEVELOPMENT_MODULE,
|
||||||
|
// REACT_DOM_PRODUCTION_MODULE,
|
||||||
|
// REACT_DOM_DEVELOPMENT_MODULE,
|
||||||
|
// REACT_DOM_CLIENT_PRODUCTION_MODULE,
|
||||||
|
// REACT_DOM_CLIENT_DEVELOPMENT_MODULE,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user