-
Notifications
You must be signed in to change notification settings - Fork 0
/
esbuild.js
34 lines (30 loc) · 891 Bytes
/
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
const fs = require('fs');
const jsdomPatch = {
name: 'jsdom-patch',
setup(build) {
build.onLoad({ filter: /jsdom\/living\/xhr\/XMLHttpRequest-impl\.js$/ }, async args => {
let contents = await fs.promises.readFile(args.path, 'utf8');
contents = contents.replace(
'const syncWorkerFile = require.resolve ? require.resolve("./xhr-sync-worker.js") : null;',
`const syncWorkerFile = "${require.resolve('jsdom/lib/jsdom/living/xhr/xhr-sync-worker.js')}";`,
);
return { contents, loader: 'js' };
});
},
};
require('esbuild').build({
entryPoints: ['src/index.ts'],
bundle: true,
minify: true,
platform: 'node',
target: 'node14',
sourcemap: 'external',
outdir: 'dist/esbuild',
plugins: [jsdomPatch],
external: ['canvas'],
assetNames: '[dir]/[name]',
loader: {
'.ejs': 'file',
}
})
.catch(() => process.exit(1))