forked from Boole-Digital/portkey-client
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.mjs
More file actions
33 lines (29 loc) · 804 Bytes
/
build.mjs
File metadata and controls
33 lines (29 loc) · 804 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
import esbuild from 'esbuild';
import { execSync } from 'child_process';
// Step 1: Generate type declarations
execSync('tsc --emitDeclarationOnly --declaration --outDir dist', { stdio: 'inherit' });
// Step 2: Build ESM
await esbuild.build({
entryPoints: ['src/index.ts'],
bundle: true,
format: 'esm',
outfile: 'dist/index.js',
external: ['react', 'react-dom']
});
// Step 3: Build CommonJS
await esbuild.build({
entryPoints: ['src/index.ts'],
bundle: true,
format: 'cjs',
outfile: 'dist/index.cjs',
external: ['react', 'react-dom']
});
// Step 4: Optionally build IIFE for demo use
await esbuild.build({
entryPoints: ['src/index.ts'],
bundle: true,
format: 'iife',
globalName: 'reactBackgroundIframe',
outfile: 'dist/bundle.js',
external: ['react', 'react-dom']
});