-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.js
More file actions
31 lines (28 loc) · 779 Bytes
/
build.js
File metadata and controls
31 lines (28 loc) · 779 Bytes
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
const esbuild = require('esbuild');
const { nodeExternalsPlugin } = require('esbuild-node-externals');
// Build for ESM
esbuild.build({
entryPoints: ['src/index.ts'],
outfile: 'dist/index.esm.js',
bundle: true,
minify: true,
platform: 'neutral',
format: 'esm',
sourcemap: true,
plugins: [nodeExternalsPlugin()],
target: ['es2020']
}).catch(() => process.exit(1));
// Build for CommonJS
esbuild.build({
entryPoints: ['src/index.ts'],
outfile: 'dist/index.cjs.js',
bundle: true,
minify: true,
platform: 'node',
format: 'cjs',
sourcemap: true,
plugins: [nodeExternalsPlugin()],
target: ['es2020']
}).catch(() => process.exit(1));
// Generate type definitions
require('child_process').execSync('tsc --emitDeclarationOnly --outDir dist/types');