Switch back to fs watcher

This commit is contained in:
Benjamin Toby 2026-04-21 16:25:57 +01:00
parent e2b8b95a4b
commit cd9ac833dc
10 changed files with 23 additions and 23 deletions

View File

@ -3,7 +3,7 @@ import type { FileSystemRouter, Server } from "bun";
import { type DirNames } from "../utils/grab-dir-names"; import { type DirNames } from "../utils/grab-dir-names";
import type { BuildContext } from "esbuild"; import type { BuildContext } from "esbuild";
import grabConstants from "../utils/grab-constants"; import grabConstants from "../utils/grab-constants";
import type { FSWatcher } from "chokidar"; import type { FSWatcher } from "fs";
/** /**
* # Declare Global Variables * # Declare Global Variables
*/ */

View File

@ -7,7 +7,7 @@ import allPagesESBuildContextBundler from "./bundler/all-pages-esbuild-context-b
import serverPostBuildFn from "./server/server-post-build-fn"; import serverPostBuildFn from "./server/server-post-build-fn";
import reactModulesBundler from "./bundler/react-modules-bundler"; import reactModulesBundler from "./bundler/react-modules-bundler";
import grabConstants from "../utils/grab-constants"; import grabConstants from "../utils/grab-constants";
import chokadirWatcherEsbuildCTX from "./server/chokidar-watcher-esbuild-ctx"; import watcherEsbuildCTX from "./server/watcher-esbuild-ctx";
const dirNames = grabDirNames(); const dirNames = grabDirNames();
const { PAGES_DIR } = dirNames; const { PAGES_DIR } = dirNames;
export default async function bunextInit() { export default async function bunextInit() {
@ -40,7 +40,7 @@ export default async function bunextInit() {
serverPostBuildFn(); serverPostBuildFn();
}, },
}); });
chokadirWatcherEsbuildCTX(); watcherEsbuildCTX();
} }
else { else {
log.build(`Building Modules ...`); log.build(`Building Modules ...`);

View File

@ -105,7 +105,7 @@ export default async function chokadirWatcherEsbuildCTX() {
.on("unlink", (path) => handleEvent("unlink", path)) .on("unlink", (path) => handleEvent("unlink", path))
.on("addDir", (path) => handleEvent("addDir", path)) .on("addDir", (path) => handleEvent("addDir", path))
.on("unlinkDir", (path) => handleEvent("unlinkDir", path)); .on("unlinkDir", (path) => handleEvent("unlinkDir", path));
global.PAGES_SRC_WATCHER = watcher; // global.PAGES_SRC_WATCHER = watcher;
} }
function reloadWatcher() { function reloadWatcher() {
if (global.PAGES_SRC_WATCHER) { if (global.PAGES_SRC_WATCHER) {

View File

@ -1,7 +1,7 @@
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 chokadirWatcherEsbuildCTX from "./chokidar-watcher-esbuild-ctx";
import serverPostBuildFn from "./server-post-build-fn"; import serverPostBuildFn from "./server-post-build-fn";
import watcherEsbuildCTX from "./watcher-esbuild-ctx";
export default async function fullRebuild(params) { export default async function fullRebuild(params) {
try { try {
const { msg } = params || {}; const { msg } = params || {};
@ -31,6 +31,6 @@ export default async function fullRebuild(params) {
} }
if (global.PAGES_SRC_WATCHER) { if (global.PAGES_SRC_WATCHER) {
global.PAGES_SRC_WATCHER.close(); global.PAGES_SRC_WATCHER.close();
chokadirWatcherEsbuildCTX(); watcherEsbuildCTX();
} }
} }

View File

@ -98,11 +98,11 @@ export default async function watcherEsbuildCTX() {
msg: `${type} ${action}: ${filename}. Rebuilding ...`, msg: `${type} ${action}: ${filename}. Rebuilding ...`,
}); });
}); });
// global.PAGES_SRC_WATCHER = pages_src_watcher; global.PAGES_SRC_WATCHER = pages_src_watcher;
} }
function reloadWatcher() { function reloadWatcher() {
// if (global.PAGES_SRC_WATCHER) { if (global.PAGES_SRC_WATCHER) {
// global.PAGES_SRC_WATCHER.close(); global.PAGES_SRC_WATCHER.close();
// watcherEsbuildCTX(); watcherEsbuildCTX();
// } }
} }

View File

@ -1,6 +1,6 @@
{ {
"name": "@moduletrace/bunext", "name": "@moduletrace/bunext",
"version": "1.0.92", "version": "1.0.93",
"main": "dist/index.js", "main": "dist/index.js",
"module": "index.ts", "module": "index.ts",
"dependencies": { "dependencies": {

View File

@ -15,8 +15,8 @@ import allPagesESBuildContextBundler from "./bundler/all-pages-esbuild-context-b
import serverPostBuildFn from "./server/server-post-build-fn"; import serverPostBuildFn from "./server/server-post-build-fn";
import reactModulesBundler from "./bundler/react-modules-bundler"; import reactModulesBundler from "./bundler/react-modules-bundler";
import grabConstants from "../utils/grab-constants"; import grabConstants from "../utils/grab-constants";
import type { FSWatcher } from "chokidar"; import watcherEsbuildCTX from "./server/watcher-esbuild-ctx";
import chokadirWatcherEsbuildCTX from "./server/chokidar-watcher-esbuild-ctx"; import type { FSWatcher } from "fs";
/** /**
* # Declare Global Variables * # Declare Global Variables
@ -95,7 +95,7 @@ export default async function bunextInit() {
serverPostBuildFn(); serverPostBuildFn();
}, },
}); });
chokadirWatcherEsbuildCTX(); watcherEsbuildCTX();
} else { } else {
log.build(`Building Modules ...`); log.build(`Building Modules ...`);
await allPagesESBuildContextBundler(); await allPagesESBuildContextBundler();

View File

@ -131,7 +131,7 @@ export default async function chokadirWatcherEsbuildCTX() {
.on("addDir", (path) => handleEvent("addDir", path)) .on("addDir", (path) => handleEvent("addDir", path))
.on("unlinkDir", (path) => handleEvent("unlinkDir", path)); .on("unlinkDir", (path) => handleEvent("unlinkDir", path));
global.PAGES_SRC_WATCHER = watcher; // global.PAGES_SRC_WATCHER = watcher;
} }
function reloadWatcher() { function reloadWatcher() {

View File

@ -1,7 +1,7 @@
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 chokadirWatcherEsbuildCTX from "./chokidar-watcher-esbuild-ctx";
import serverPostBuildFn from "./server-post-build-fn"; import serverPostBuildFn from "./server-post-build-fn";
import watcherEsbuildCTX from "./watcher-esbuild-ctx";
export default async function fullRebuild(params?: { msg?: string }) { export default async function fullRebuild(params?: { msg?: string }) {
try { try {
@ -38,6 +38,6 @@ export default async function fullRebuild(params?: { msg?: string }) {
if (global.PAGES_SRC_WATCHER) { if (global.PAGES_SRC_WATCHER) {
global.PAGES_SRC_WATCHER.close(); global.PAGES_SRC_WATCHER.close();
chokadirWatcherEsbuildCTX(); watcherEsbuildCTX();
} }
} }

View File

@ -128,12 +128,12 @@ export default async function watcherEsbuildCTX() {
}, },
); );
// global.PAGES_SRC_WATCHER = pages_src_watcher; global.PAGES_SRC_WATCHER = pages_src_watcher;
} }
function reloadWatcher() { function reloadWatcher() {
// if (global.PAGES_SRC_WATCHER) { if (global.PAGES_SRC_WATCHER) {
// global.PAGES_SRC_WATCHER.close(); global.PAGES_SRC_WATCHER.close();
// watcherEsbuildCTX(); watcherEsbuildCTX();
// } }
} }