-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(esbuild): different builds cjs/ems/iife
- Loading branch information
1 parent
28f9189
commit a7554a8
Showing
2 changed files
with
41 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,46 @@ | ||
import { build } from 'esbuild'; | ||
import browserslistToEsbuild from 'browserslist-to-esbuild'; | ||
|
||
build({ | ||
entryPoints: ['./src/index.js'], | ||
const inputs = [ | ||
{ src: './src/index.js', name: 'basics.vector', target: '' }, | ||
{ src: './src/operator.js', name: 'basics.vector.operator' }, | ||
{ src: './src/adapter/playcanvas.js', name: 'basics.vector.adapter.playcanvas'} | ||
]; | ||
|
||
const defaultOptions = { | ||
bundle: true, | ||
minify: true, | ||
sourcemap: true, | ||
treeShaking: true, | ||
target: browserslistToEsbuild(), | ||
outfile: './build/out.js', | ||
}).catch(() => global.process.exit(1)); | ||
mainFields: ['module', 'main'], | ||
outbase: 'src' | ||
}; | ||
|
||
inputs.forEach((item) => { | ||
build({ | ||
...defaultOptions, | ||
entryPoints: [item.src], | ||
format: 'iife', | ||
globalName: item.name, | ||
outdir: './build/iife', | ||
}).catch(() => global.process.exit(1)); | ||
|
||
build({ | ||
...defaultOptions, | ||
entryPoints: [item.src], | ||
format: 'esm', | ||
splitting: true, | ||
outdir: './build/esm/', | ||
outExtension: { '.js': '.mjs' } | ||
}).catch(() => global.process.exit(1)); | ||
|
||
build({ | ||
...defaultOptions, | ||
entryPoints: [item.src], | ||
format: 'cjs', | ||
outdir: './build/cjs/', | ||
outExtension: { '.js': '.cjs' } | ||
}).catch(() => global.process.exit(1)); | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters