mirror of
https://github.com/tribufu/node-gamedig
synced 2026-05-06 15:17:36 +00:00
Test esbuild to generate ESModule and CommonJS
This commit is contained in:
parent
46db10fcc7
commit
4764ec2e64
6 changed files with 689 additions and 7 deletions
28
tools/esbuild.js
Normal file
28
tools/esbuild.js
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
import { build } from 'esbuild'
|
||||
import { nodeExternalsPlugin } from 'esbuild-node-externals'
|
||||
|
||||
const baseConfig = {
|
||||
entryPoints: ['lib/index.js'],
|
||||
platform: 'node',
|
||||
target: 'node14',
|
||||
bundle: true,
|
||||
minify: false,
|
||||
sourcemap: false,
|
||||
legalComments: 'none',
|
||||
plugins: [nodeExternalsPlugin()]
|
||||
}
|
||||
|
||||
const moduleConfig = {
|
||||
...baseConfig,
|
||||
outfile: 'dist/index.mjs',
|
||||
format: 'esm'
|
||||
}
|
||||
|
||||
const legacyConfig = {
|
||||
...baseConfig,
|
||||
outfile: 'dist/index.cjs',
|
||||
format: 'cjs'
|
||||
}
|
||||
|
||||
build(moduleConfig).then(() => { }).catch(() => { process.exit(1) })
|
||||
build(legacyConfig).then(() => { }).catch(() => { process.exit(1) })
|
||||
Loading…
Add table
Add a link
Reference in a new issue