Refactor Server Paradigm.

This commit is contained in:
2026-03-24 07:18:57 +01:00
parent 342f56f3f5
commit 60ee353bf0
34 changed files with 425 additions and 279 deletions
+2 -11
View File
@@ -1,13 +1,11 @@
import ora, {} from "ora";
import grabDirNames from "../utils/grab-dir-names";
import { readFileSync } from "fs";
import {} from "fs";
import init from "./init";
import isDevelopment from "../utils/is-development";
import allPagesBundler from "./bundler/all-pages-bundler";
import watcher from "./server/watcher";
import { log } from "../utils/log";
import cron from "./server/cron";
import EJSON from "../utils/ejson";
import allPagesBunBundler from "./bundler/all-pages-bun-bundler";
const { PAGES_DIR, HYDRATION_DST_DIR_MAP_JSON_FILE } = grabDirNames();
export default async function bunextInit() {
@@ -17,6 +15,7 @@ export default async function bunextInit() {
global.BUNDLER_CTX_MAP = {};
global.BUNDLER_REBUILDS = 0;
global.PAGE_FILES = [];
global.SKIPPED_BROWSER_MODULES = new Set();
await init();
log.banner();
const router = new Bun.FileSystemRouter({
@@ -26,17 +25,9 @@ export default async function bunextInit() {
global.ROUTER = router;
const is_dev = isDevelopment();
if (is_dev) {
// await allPagesBundler();
await allPagesBunBundler();
watcher();
}
else {
const artifacts = EJSON.parse(readFileSync(HYDRATION_DST_DIR_MAP_JSON_FILE, "utf-8"));
if (!artifacts) {
log.error("Please build first.");
process.exit(1);
}
global.BUNDLER_CTX_MAP = artifacts;
cron();
}
}