Skip to content
This repository was archived by the owner on Mar 3, 2025. It is now read-only.

Commit 26bd633

Browse files
carlopivpbs2
authored andcommitted
Trick esbuild: static analyzer is smart enough to recognize a potential problem, but not to see condition that avoids it
Rewrite code as per duckdb#1530 to fix these problems while having equivalent code
1 parent adfc27c commit 26bd633

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

packages/duckdb-wasm/bundle.mjs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,13 @@ fs.copyFile(path.resolve(src, 'bindings', 'duckdb-coi.wasm'), path.resolve(dist,
132132
});
133133

134134
console.log('[ ESBUILD ] duckdb-browser-blocking.cjs');
135+
// Don't attempt to bundle NodeJS modules in the browser build.
136+
execSync(
137+
`sed -i.bak 's/require("child_process")/["child_process"].map(require)/g' ./src/bindings/duckdb-mvp.js && rm ./src/bindings/duckdb-mvp.js.bak`,
138+
);
139+
execSync(
140+
`sed -i.bak 's/require("child_process")/["child_process"].map(require)/g' ./src/bindings/duckdb-eh.js && rm ./src/bindings/duckdb-eh.js.bak`,
141+
);
135142
await esbuild.build({
136143
entryPoints: ['./src/targets/duckdb-browser-blocking.ts'],
137144
outfile: 'dist/duckdb-browser-blocking.cjs',

0 commit comments

Comments
 (0)