Skip to content

Commit

Permalink
add cjs and ejm builds (#21)
Browse files Browse the repository at this point in the history
Co-authored-by: acruikshank <[email protected]>
  • Loading branch information
acruikshank and acruikshank authored Jul 13, 2021
1 parent ac8ebb2 commit 81e38e4
Showing 1 changed file with 34 additions and 19 deletions.
53 changes: 34 additions & 19 deletions esbuild.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,41 @@
const esbuild = require('esbuild')
const path = require("path")
const {compressionBrowserPlugin, wasmPlugin} = require("./esbuild-plugins");
// esbuild has TypeScript support by default
const outfile = 'parquet-bundle.min.js'
require('esbuild')
.build({
bundle: true,
entryPoints: ['parquet.js'],
outdir: path.resolve(__dirname, "dist","browser"),
define: {
"process.env.NODE_DEBUG": false,
"process.env.NODE_ENV": "\"production\"",
global: "window"
},
const baseConfig = {
bundle: true,
entryPoints: ['parquet.js'],
define: {
"process.env.NODE_DEBUG": false,
"process.env.NODE_ENV": "\"production\"",
global: "window"
},
inject: ['./esbuild-shims.js'],
minify: true,
platform: 'browser', // default
plugins: [compressionBrowserPlugin, wasmPlugin],
target: "es2020" // default
};
const targets = [
{
...baseConfig,
globalName: 'parquetjs',
inject: ['./esbuild-shims.js'],
minify: true,
platform: 'browser', // default
plugins: [compressionBrowserPlugin, wasmPlugin],
target: "esnext" // default
})
.then(res => {
if (!res.warnings.length) {
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"),
}
]
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")
}
})
Expand Down

0 comments on commit 81e38e4

Please sign in to comment.