Skip to content

Commit 1ed46c0

Browse files
committed
fix: move rmSync before esbuild so dist-pkg/api-server.mjs survives
The rmSync was placed after esbuild, deleting the JS bundle before WASM files were copied. Moved it before esbuild so the directory is cleaned first, then esbuild writes the bundle, then WASM files are copied alongside it.
1 parent 12ec688 commit 1ed46c0

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

apps/api/scripts/bundle.mjs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ const replaceDynamicImports = {
5959
},
6060
}
6161

62+
// Clean output directory to avoid stale artifacts.
63+
fs.rmSync(outDir, { recursive: true, force: true })
64+
fs.mkdirSync(outDir, { recursive: true })
65+
6266
await build({
6367
entryPoints: [path.join(root, "src/index.ts")],
6468
bundle: true,
@@ -85,10 +89,6 @@ await build({
8589
// Search the pnpm store since these packages are transitive deps.
8690
const WASM_PACKAGES = ["node-sqlite3-wasm", "mupdf", "@resvg/resvg-wasm"]
8791

88-
// Avoid stale .wasm artifacts causing false-positive verification passes.
89-
fs.rmSync(outDir, { recursive: true, force: true })
90-
fs.mkdirSync(outDir, { recursive: true })
91-
9292
for (const pkg of WASM_PACKAGES) {
9393
const pnpmDir = path.join(monorepoRoot, "node_modules/.pnpm")
9494
const safeName = pkg.replace(/\//g, "+").replace(/@/g, "")

0 commit comments

Comments
 (0)