-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathbundle.mjs
More file actions
43 lines (40 loc) · 1.09 KB
/
Copy pathbundle.mjs
File metadata and controls
43 lines (40 loc) · 1.09 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
import fs from 'fs';
import { build } from 'esbuild';
import { polyfillNode } from 'esbuild-plugin-polyfill-node';
const bundle = async () => {
console.log('Building minified web bundle file.');
return build({
entryPoints: ['./src/solana/index.ts'],
bundle: true,
minify: true,
platform: 'browser',
target: ['esnext'],
format: 'esm',
globalName: 'ar.io',
plugins: [
/**
* Polyfill the Node primitives Solana code touches (currently
* `crypto.createHash` from src/solana/ant-readable.ts). `process` /
* `buffer` keep transitive deps happy in the browser.
*/
polyfillNode({
polyfills: {
crypto: true,
process: true,
buffer: true,
},
}),
],
external: ['commander', 'prompts'],
tsconfig: './tsconfig.json',
outfile: './bundles/web.bundle.min.js',
metafile: true,
}).catch((e) => {
console.log(e);
process.exit(1);
});
};
const result = await bundle();
if (result.metafile) {
fs.writeFileSync('./metafile.json', JSON.stringify(result.metafile, null, 2));
}