-
Notifications
You must be signed in to change notification settings - Fork 7
/
esbuild.mjs
48 lines (46 loc) · 1.06 KB
/
esbuild.mjs
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
import path from 'path'
import esbuild from 'esbuild'
import GlobalsPlugin from 'esbuild-plugin-globals'
// Node.js target build
await esbuild.build({
entryPoints: [path.join(process.cwd(), 'index.js')],
loader: { '.xml': 'text' },
outdir: path.join(process.cwd(), 'dist', 'commonjs'),
target: 'node18',
bundle: true,
sourcemap: true,
platform: 'node',
})
// Browser target build
await esbuild.build({
entryPoints: [path.join(process.cwd(), 'index.js')],
loader: { '.xml': 'text' },
outdir: path.join(process.cwd(), 'dist', 'esm'),
bundle: true,
sourcemap: true,
format: 'esm',
external: ['pluralize'],
define: {
global: 'globalThis',
window: 'globalThis',
crypto: 'globalThis',
os: 'globalThis',
timers: 'globalThis',
process: JSON.stringify({
env: {},
argv: [],
stdout: '',
stderr: '',
stdin: '',
version: 'v12.14.1',
}),
},
plugins: [
GlobalsPlugin({
crypto: 'globalThis',
os: 'globalThis',
timers: 'globalThis',
process: 'globalThis',
}),
],
})