forked from LibertyDSNP/parquetjs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
esbuild.js
70 lines (67 loc) · 1.96 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
const esbuild = require('esbuild')
const path = require("path")
const {compressionBrowserPlugin, wasmPlugin} = require("./esbuild-plugins");
// esbuild has TypeScript support by default
const baseConfig = {
bundle: true,
entryPoints: ['parquet.ts'],
define: {
"process.env.NODE_DEBUG": "false",
"process.env.NODE_ENV": "\"production\"",
global: "window"
},
inject: ['./esbuild-shims.js'],
minify: true,
mainFields: ["browser", "module", "main"],
platform: 'browser', // default
plugins: [compressionBrowserPlugin, wasmPlugin],
target: "es2020" // default
};
// configuration for generating test code in browser
const testConfig = {
bundle: true,
entryPoints: ['test/browser/main.ts'],
define: {
"process.env.NODE_DEBUG": "false",
"process.env.NODE_ENV": "\"production\"",
global: "window"
},
inject: ['./esbuild-shims.js'],
minify: false,
mainFields: ["browser", "module", "main"],
platform: 'browser', // default
plugins: [compressionBrowserPlugin, wasmPlugin],
target: "es2020" // default
}
const targets = [
{
...baseConfig,
globalName: 'parquetjs',
outdir: path.resolve(__dirname, "dist","browser"),
},
{
...baseConfig,
format: "esm",
outfile: path.resolve(__dirname, "dist","browser","parquet.esm.js"),
},
{
...baseConfig,
format: "cjs",
outfile: path.resolve(__dirname, "dist","browser","parquet.cjs.js"),
},
// Browser test code below
{
...testConfig,
outfile: path.resolve(__dirname, "test","browser","main.js"),
}
]
Promise.all(targets.map(esbuild.build))
.then(results => {
if (results.reduce((m,r)=>m && !r.warnings.length, true)) {
console.log("built with no errors or warnings")
}
})
.catch(e => {
console.error("Finished with errors: ", e.toString());
process.exit(1);
});