-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.mjs
52 lines (47 loc) · 1002 Bytes
/
build.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import dts from "bun-plugin-dts";
import path from "path";
const nodeBuffer = {
name: "node buffer in the frontend",
setup(build) {
build.onResolve({ filter: /^buffer$/ }, (args) => {
const path_to_buffer_lib = path.resolve(
"./",
"node_modules/buffer/index.js"
);
if (path_to_buffer_lib)
return {
path: path_to_buffer_lib,
};
});
},
};
const output = await Bun.build({
entrypoints: ["./src/index.ts"],
outdir: "./dist",
target: "browser",
minify: false,
plugins: [dts(), nodeBuffer],
define: {
global: "window",
},
});
if (!output.success) {
for (const log of output.logs) {
console.error(log);
}
}
const output2 = await Bun.build({
entrypoints: ["./src/index.ts"],
outdir: "./dist_node",
target: "node",
minify: false,
plugins: [dts(), nodeBuffer],
define: {
window: "undefined",
},
});
if (!output2.success) {
for (const log of output2.logs) {
console.error(log);
}
}