Fix watcher rebuild on page add and delete

This commit is contained in:
2026-10-13 15:18:41 +01:00
parent 7bab610b38
commit 4238d9a4ea
7 changed files with 153 additions and 27 deletions
@@ -16,6 +16,16 @@ const { HYDRATION_DST_DIR, BUNX_HYDRATION_SRC_DIR } = grabDirNames();
// be recreated (entry points are fixed at context creation).
let last_entry_keys = undefined;
let last_root_file_path = undefined;
// Local paths of the pages that made it into the current entry set. Pages
// skipped at build time (e.g. created empty, no default export yet) are
// absent, so the watcher can treat their later edits as structural.
let last_entry_pages = new Set();
/**
* True when `local_path` is a hydration entry of the current esbuild context.
*/
export function isHydrationEntryPage(local_path) {
return last_entry_pages.has(local_path);
}
function arraysEqual(a, b) {
if (a.length !== b.length)
return false;
@@ -97,6 +107,7 @@ export default async function allPagesESBuildContextBundler(params) {
});
last_entry_keys = entry_keys;
last_root_file_path = root_file_path;
last_entry_pages = new Set([...entryToPage.values()].map((p) => p.local_path));
}
await global.BUNEXT_BUNDLER_CTX.rebuild();
}