Add support to CommonJS

This commit is contained in:
Guilherme Werner 2024-01-27 19:20:53 -03:00
parent 0bf6645921
commit 91a38084d2
6 changed files with 678 additions and 4 deletions

15
tools/esbuild.js Normal file
View file

@ -0,0 +1,15 @@
import { build } from 'esbuild'
import { nodeExternalsPlugin } from 'esbuild-node-externals'
const buildConfig = {
entryPoints: ['lib/index.js'],
platform: 'node',
target: 'node14',
bundle: true,
outfile: 'dist/index.cjs',
format: 'cjs',
// got is a esm module, so we need to add it to the allowList, to include it in the bundle.
plugins: [nodeExternalsPlugin({ allowList: ['got'] })]
}
build(buildConfig).then(() => { }).catch(() => { process.exit(1) })