-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.js
23 lines (21 loc) · 798 Bytes
/
build.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
const { build } = require('esbuild')
const { rmSync } = require('fs')
let makeAllPackagesExternalPlugin = {
name: 'make-all-packages-external',
setup(build) {
let filter = /^[^.\/]|^\.[^.\/]|^\.\.[^\/]/ // Must not start with "/" or "./" or "../"
build.onResolve({ filter }, args => ({ path: args.path, external: true }))
},
}
rmSync('dist', { recursive: true, force: true });
build({
plugins: [makeAllPackagesExternalPlugin], //Comment to use ESM
bundle: true,
format: 'cjs',
platform: 'node',
target: 'node14',
entryPoints: ['./src/app.ts'],
// external: ['express','deta'], //Add cjs modules here when disabling the plugin above
outfile: './dist/index.js'
}).then(() => console.log('Build completed.'))
.catch(err => console.error(err));