Refactor Bundler. Fix bugs.

This commit is contained in:
2026-03-24 22:03:55 +01:00
parent 336fa812a5
commit 321c8ebb89
25 changed files with 387 additions and 167 deletions
@@ -52,8 +52,6 @@ export default async function watcherEsbuildCTX() {
if (global.RECOMPILING) return;
global.RECOMPILING = true;
log.info(`Rebuilding CTX ...`);
await global.BUNDLER_CTX?.rebuild();
if (filename.match(/(404|500)\.tsx?/)) {
@@ -107,28 +105,21 @@ async function fullRebuild(params?: { msg?: string }) {
log.watch(msg);
}
log.info(`Reloading Router ...`);
global.ROUTER.reload();
log.info(`Disposing Bundler CTX ...`);
await global.BUNDLER_CTX?.dispose();
global.BUNDLER_CTX = undefined;
global.BUNDLER_CTX_MAP = {};
log.info(`Rebuilding Modules ...`);
allPagesESBuildContextBundler({
post_build_fn: serverPostBuildFn,
});
} catch (error: any) {
log.error(error);
} finally {
global.RECOMPILING = false;
}
if (global.PAGES_SRC_WATCHER) {
log.info(`Restarting watcher ...`);
global.PAGES_SRC_WATCHER.close();
watcherEsbuildCTX();
}