|
| 1 | +const esbuild = require('esbuild') |
1 | 2 | const path = require("path")
|
2 | 3 | const {compressionBrowserPlugin, wasmPlugin} = require("./esbuild-plugins");
|
3 | 4 | // esbuild has TypeScript support by default
|
4 |
| -const outfile = 'parquet-bundle.min.js' |
5 |
| -require('esbuild') |
6 |
| - .build({ |
7 |
| - bundle: true, |
8 |
| - entryPoints: ['parquet.js'], |
9 |
| - outdir: path.resolve(__dirname, "dist","browser"), |
10 |
| - define: { |
11 |
| - "process.env.NODE_DEBUG": false, |
12 |
| - "process.env.NODE_ENV": "\"production\"", |
13 |
| - global: "window" |
14 |
| - }, |
| 5 | +const baseConfig = { |
| 6 | + bundle: true, |
| 7 | + entryPoints: ['parquet.js'], |
| 8 | + define: { |
| 9 | + "process.env.NODE_DEBUG": false, |
| 10 | + "process.env.NODE_ENV": "\"production\"", |
| 11 | + global: "window" |
| 12 | + }, |
| 13 | + inject: ['./esbuild-shims.js'], |
| 14 | + minify: true, |
| 15 | + platform: 'browser', // default |
| 16 | + plugins: [compressionBrowserPlugin, wasmPlugin], |
| 17 | + target: "es2020" // default |
| 18 | +}; |
| 19 | +const targets = [ |
| 20 | + { |
| 21 | + ...baseConfig, |
15 | 22 | globalName: 'parquetjs',
|
16 |
| - inject: ['./esbuild-shims.js'], |
17 |
| - minify: true, |
18 |
| - platform: 'browser', // default |
19 |
| - plugins: [compressionBrowserPlugin, wasmPlugin], |
20 |
| - target: "esnext" // default |
21 |
| - }) |
22 |
| - .then(res => { |
23 |
| - if (!res.warnings.length) { |
| 23 | + outdir: path.resolve(__dirname, "dist","browser"), |
| 24 | + }, |
| 25 | + { |
| 26 | + ...baseConfig, |
| 27 | + format: "esm", |
| 28 | + outfile: path.resolve(__dirname, "dist","browser","parquet.esm.js"), |
| 29 | + }, |
| 30 | + { |
| 31 | + ...baseConfig, |
| 32 | + format: "cjs", |
| 33 | + outfile: path.resolve(__dirname, "dist","browser","parquet.cjs.js"), |
| 34 | + } |
| 35 | +] |
| 36 | +Promise.all(targets.map(esbuild.build)) |
| 37 | + .then(results => { |
| 38 | + if (results.reduce((m,r)=>m && !r.warnings.length, true)) { |
24 | 39 | console.log("built with no errors or warnings")
|
25 | 40 | }
|
26 | 41 | })
|
|
0 commit comments