From 6ba750793881225905ca004ee545ee1870783bfc Mon Sep 17 00:00:00 2001 From: Gary Ingle Date: Sun, 12 Apr 2026 19:05:14 +0200 Subject: [PATCH] fix: add missing await on mkdir and node:module external in esbuild config - Add await to fs.mkdir() call in generateDevices() (line 60). Without this, writeFile can race ahead of directory creation, causing ENOENT on clean builds or slower machines. - Add 'node:module' to the externals array. Node.js treats 'module' and 'node:module' as distinct specifiers; esbuild fails to resolve the prefixed form when bundling for the browser target. Discovered during Docker builds on ARM64 where the race window is wider due to slower I/O. Also reproduces on x86_64 with a clean src/pack/. --- bin/esbuild.config.mjs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bin/esbuild.config.mjs b/bin/esbuild.config.mjs index 11b24998..07d98d10 100644 --- a/bin/esbuild.config.mjs +++ b/bin/esbuild.config.mjs @@ -57,7 +57,7 @@ async function generateDevices(dir = '') { } } let dstr = JSON.stringify(devs); - fs.mkdir(path.join(dir, "src", "pack"), { recursive: true }); + await fs.mkdir(path.join(dir, "src", "pack"), { recursive: true }); await fs.writeFile(path.join(dir, "src", "pack", "kiri-devs.js"), `export const devices = ${dstr};`); if (true) { // create alt artifacts @@ -77,6 +77,7 @@ const rec = { define: { 'process.env.NODE_ENV': `"${mode}"` }, external: [ 'module', + 'node:module', './constants', './voronoi_structures', './voronoi_ctypes',