-
Notifications
You must be signed in to change notification settings - Fork 14
/
esbuild.package.js
32 lines (29 loc) · 1009 Bytes
/
esbuild.package.js
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
const { dtsPlugin } = require("esbuild-plugin-d.ts");
const { build } = require("esbuild");
let makeAllPackagesExternalPlugin = {
name: 'make-all-packages-external',
setup(build) {
build.onResolve({ filter: /protocol/ }, args => ({ external: false }))
let filter = /^[^.\/]|^\.[^.\/]|^\.\.[^\/]/ // Must not start with "/" or "./" or "../"
build.onResolve({ filter }, args => ({ path: args.path, external: true }))
},
}
for (let project of ["client", "protocol", "tracker-list"]) {
build({
bundle: true,
format: "esm",
entryPoints: [`./${project}/src/index.ts`],
outfile: `./dist/${project}.mjs`,
plugins: [makeAllPackagesExternalPlugin]
})
build({
bundle: true,
format: "cjs",
entryPoints: [`./${project}/src/index.ts`],
outfile: `./dist/${project}.cjs`,
plugins: [dtsPlugin({
outDir: `./dist/${project}`,
tsconfig: "tsconfig.json"
})]
})
}