-
Notifications
You must be signed in to change notification settings - Fork 61
/
Copy pathbuild.js
executable file
·44 lines (39 loc) · 1021 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
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env node
import pkg from './package.json' assert { type: 'json' };
import esbuild from 'esbuild';
esbuild.buildSync({
sourcemap: true,
platform: 'neutral',
bundle: true,
entryPoints: ['./src/index.ts'],
outfile: './dist/index.js',
external: [
...Object.keys(pkg.dependencies || {}),
...Object.keys(pkg.peerDependencies || {}),
],
});
esbuild.buildSync({
format: 'cjs',
platform: 'neutral',
bundle: true,
sourcemap: true,
entryPoints: ['./src/index.ts'],
// If use `type: module` in package.json, the extension of the output file should be `.cjs`
outfile: './dist/index.cjs',
external: [
...Object.keys(pkg.dependencies || {}),
...Object.keys(pkg.peerDependencies || {}),
],
});
esbuild.buildSync({
format: 'esm',
platform: 'neutral',
bundle: true,
sourcemap: true,
entryPoints: ['./src/index.ts'],
outfile: './dist/index.esm.js',
external: [
...Object.keys(pkg.dependencies || {}),
...Object.keys(pkg.peerDependencies || {}),
],
});