Fork of github.com/did-method-plc/did-method-plc
1const pkgJson = require('@npmcli/package-json')
2const { nodeExternalsPlugin } = require('esbuild-node-externals')
3
4const buildShallow =
5 process.argv.includes('--shallow') || process.env.PLC_BUILD_SHALLOW === 'true'
6
7if (process.argv.includes('--update-main-to-dist')) {
8 return pkgJson
9 .load(__dirname)
10 .then((pkg) => pkg.update({ main: 'dist/index.js' }))
11 .then((pkg) => pkg.save())
12}
13
14require('esbuild').build({
15 logLevel: 'info',
16 entryPoints: [
17 'src/index.ts',
18 'src/bin.ts',
19 'src/db/index.ts',
20 ],
21 bundle: true,
22 sourcemap: true,
23 treeShaking: true,
24 outdir: 'dist',
25 platform: 'node',
26 assetNames: 'src/static',
27 plugins: buildShallow ? [nodeExternalsPlugin()] : [],
28 external: [
29 // Referenced in pg driver, but optional and we don't use it
30 'pg-native',
31 ],
32})