-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathesbuild.js
44 lines (38 loc) · 1.11 KB
/
esbuild.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
import { ok } from 'node:assert';
import * as eik from '@eik/esbuild-plugin';
import esbuild from 'esbuild';
// maps React versions to import map file versions.
// Add more mappings here when new versions of React become available.
const versions = new Map([
['17', 'v2'],
['18', 'v3'],
]);
const version = process.argv[2];
const reactVersions = Array.from(versions.keys());
ok(reactVersions.includes(version), `Version argument is required. Must be one of: ${reactVersions.join(',')}. Eg. 'node esbuild.mjs 18'`);
await eik.load({
urls: [`https://assets.finn.no/map/react/${versions.get(version)}`],
});
// legacy support for older filenames
if (version === '17') {
await esbuild.build({
plugins: [eik.plugin()],
entryPoints: ['packages/index.ts'],
bundle: true,
outfile: `dist/eik/index.js`,
format: 'esm',
sourcemap: true,
target: 'es2017',
minify: true,
});
}
await esbuild.build({
plugins: [eik.plugin()],
entryPoints: ['packages/index.ts'],
bundle: true,
outfile: `dist/eik/warp-react-${version}.js`,
format: 'esm',
sourcemap: true,
target: 'es2017',
minify: true,
});