-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.js
More file actions
48 lines (44 loc) · 1.04 KB
/
Copy pathbuild.js
File metadata and controls
48 lines (44 loc) · 1.04 KB
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
const { build } = require('esbuild');
const entryFile = 'src/index.ts';
/** @type {import('esbuild').BuildOptions} */
const opts = {
entryPoints: { pally: entryFile },
bundle: true,
outdir: 'dist',
sourcemap: true,
sourcesContent: false,
};
/** @type {import('esbuild').BuildOptions} */
const node = {
entryPoints: { 'pally.node': entryFile },
platform: 'node',
};
/** @type {import('esbuild').BuildOptions} */
const browser = {
platform: 'browser',
minify: true,
};
/** @type {import('esbuild').BuildOptions} */
const esm = {
outExtension: { '.js': '.mjs' },
format: 'esm',
};
/** @type {import('esbuild').BuildOptions} */
const cjs = {
outExtension: { '.js': '.cjs' },
format: 'cjs',
};
/** @type {import('esbuild').BuildOptions} */
const iife = {
outExtension: { '.js': '.js' },
format: 'iife',
globalName: 'Pally',
};
// Node ESM
build({ ...opts, ...node, ...esm });
// Node CJS
build({ ...opts, ...node, ...cjs });
// Browser ESM
build({ ...opts, ...browser, ...esm });
// Browser IIFE
build({ ...opts, ...browser, ...iife });