Skip to content

Commit a7772b3

Browse files
committed
fix: Exclude sourcemaps from node_modules
Exclude DuckDB types Signed-off-by: Gordon Smith <[email protected]>
1 parent d179a54 commit a7772b3

File tree

2 files changed

+33
-11
lines changed

2 files changed

+33
-11
lines changed

esbuild.mjs

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as process from "process";
22
import * as esbuild from "esbuild";
3+
import { readFileSync } from "fs";
34
import { umdWrapper } from "esbuild-plugin-umd-wrapper";
45
import yargs from "yargs";
56
import { hideBin } from "yargs/helpers";
@@ -25,11 +26,29 @@ myYargs
2526
;
2627
const argv = await myYargs.argv;
2728

29+
const excludeSourceMapPlugin = ({ filter }) => ({
30+
name: 'excludeSourceMapPlugin',
31+
setup(build) {
32+
build.onLoad({ filter }, (args) => {
33+
return {
34+
contents:
35+
readFileSync(args.path, 'utf8') +
36+
'\n//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIiJdLCJtYXBwaW5ncyI6IkEifQ==',
37+
loader: 'default',
38+
};
39+
});
40+
},
41+
});
42+
2843
function build(config) {
2944
argv.debug && console.log("Start: ", config.entryPoints[0], config.outfile);
3045
return esbuild.build({
3146
...config,
32-
sourcemap: true
47+
sourcemap: "linked",
48+
plugins: [
49+
...config.plugins ?? [],
50+
excludeSourceMapPlugin({ filter: /node_modules/ }),
51+
]
3352
}).then(() => {
3453
argv.debug && console.log("Stop: ", config.entryPoints[0], config.outfile);
3554
});
@@ -38,15 +57,19 @@ function build(config) {
3857
function watch(config) {
3958
return esbuild.context({
4059
...config,
41-
sourcemap: "external",
42-
plugins: [...config.plugins ?? [], {
43-
name: "rebuild-notify",
44-
setup(build) {
45-
build.onEnd(result => {
46-
console.log(`Built ${config.outfile}`);
47-
});
48-
},
49-
}]
60+
sourcemap: "linked",
61+
plugins: [
62+
...config.plugins ?? [],
63+
excludeSourceMapPlugin({ filter: /node_modules/ }),
64+
{
65+
name: "rebuild-notify",
66+
setup(build) {
67+
build.onEnd(result => {
68+
console.log(`Built ${config.outfile}`);
69+
});
70+
},
71+
}
72+
]
5073
}).then(ctx => {
5174
return ctx.watch();
5275
});

src-ts/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,3 @@ export namespace Zstd {
2323
return import("./zstd.js").then(mod => mod.Zstd.load());
2424
}
2525
}
26-
export type * from "@duckdb/duckdb-wasm";

0 commit comments

Comments
 (0)