mirror of
https://github.com/MercuryWorkshop/adrift.git
synced 2025-05-12 05:50:00 -04:00
32 lines
1,009 B
JavaScript
32 lines
1,009 B
JavaScript
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"
|
|
})]
|
|
})
|
|
}
|