-
Notifications
You must be signed in to change notification settings - Fork 2
/
esbuild.config.js
53 lines (45 loc) · 1017 Bytes
/
esbuild.config.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
45
46
47
48
49
50
51
52
53
#!/usr/bin/env node
import esbuild from 'esbuild'
const stripNodeColonPlugin = {
name: 'strip-node-colon',
setup({onResolve}) {
onResolve(
{filter: /^node:/},
args => ({path: args.path.slice('node:'.length), external: true}),
)
},
}
console.time('build')
const commonOpions = {
entryPoints: ['src/plugin.js'],
bundle: true,
sourcemap: false,
minify: false,
splitting: false,
platform: 'node',
target: ['node14'],
}
// const esm = esbuild.build({
// ...commonOpions,
// format: 'esm',
// external: ['node:path', 'node:fs', 'got', 'is-svg', 'file-type', 'debug'],
// outfile: 'dist/esm/plugin.js',
// })
const cjs = esbuild.build({
...commonOpions,
format: 'cjs',
external: ['node:path', 'node:fs'],
outfile: 'dist/plugin.cjs',
plugins: [stripNodeColonPlugin],
})
// const builds = [esm, cjs]
const builds = [cjs]
try {
const results = await Promise.all(builds)
console.log(results)
} catch (error) {
console.error(error)
process.exit(1)
} finally {
console.timeEnd('build')
}