-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathesbuild.js
More file actions
36 lines (32 loc) · 737 Bytes
/
Copy pathesbuild.js
File metadata and controls
36 lines (32 loc) · 737 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
32
33
34
35
36
import esbuild from 'esbuild';
import { nodeExternalsPlugin } from 'esbuild-node-externals';
import { rimrafSync } from 'rimraf';
rimrafSync('dist');
const options = {
entryPoints: ['src/index.ts'],
bundle: true,
tsconfig: 'tsconfig.json',
platform: 'node',
target: 'es2022',
plugins: [nodeExternalsPlugin()],
};
esbuild
.build({
...options,
format: 'esm',
banner: {
js: `if (!global.require) {
const { createRequire } = await import('module');
global.require = createRequire(import.meta.url);
}`,
},
outfile: 'dist/index.mjs',
})
.catch(() => process.exit(1));
esbuild
.build({
...options,
format: 'cjs',
outfile: 'dist/index.cjs',
})
.catch(() => process.exit(1));