Repository navigation
Expand file tree
/
Copy pathbuild.js
More file actions
42 lines (40 loc) · 1.45 KB
/
Copy pathbuild.js
File metadata and controls
42 lines (40 loc) · 1.45 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
const esbuild = require('esbuild');
/**
* One build for every entry, with code splitting, so a module such as errors.ts or the route
* table exists once in dist and every entry imports that same instance. Bundling each entry on
* its own would give `@relax.js/core` and `@relax.js/core/routing` separate copies of shared
* state, and an onError() handler registered through one would never see errors reported
* through the other.
*/
const entryPoints = {
index: 'src/index.ts',
'html/index': 'src/html/index.ts',
'http/index': 'src/http/index.ts',
'forms/index': 'src/forms/index.ts',
'routing/index': 'src/routing/index.ts',
'i18n/index': 'src/i18n/index.ts',
'elements/index': 'src/elements/index.ts',
'utils/index': 'src/utils/index.ts',
'di/index': 'src/di/index.ts',
'collections/index': 'src/collections/Index.ts',
'testing/index': 'src/testing/index.ts',
'check/index': 'src/check/index.ts',
'prerender/index': 'src/prerender/index.ts',
};
esbuild
.build({
entryPoints,
outdir: 'dist',
outExtension: { '.js': '.mjs' },
format: 'esm',
splitting: true,
chunkNames: 'chunks/[name]-[hash]',
bundle: true,
external: ['typescript', 'playwright', 'node:*'],
minify: true,
target: 'es2022',
sourcemap: true,
preserveSymlinks: true,
})
.then(() => console.log('Build complete'))
.catch(() => process.exit(1));