mirror of
https://github.com/nbd-wtf/nostr-tools.git
synced 2025-12-10 17:18:51 +00:00
build for commonjs, esm and a standalone bundle.
This commit is contained in:
29
build.cjs
29
build.cjs
@@ -2,24 +2,35 @@
|
||||
|
||||
const esbuild = require('esbuild')
|
||||
const alias = require('esbuild-plugin-alias')
|
||||
const nodeGlobals = require('@esbuild-plugins/node-globals-polyfill').default
|
||||
|
||||
const buildOptions = {
|
||||
entryPoints: ['index.js'],
|
||||
outfile: 'nostr.js',
|
||||
let common = {
|
||||
entryPoints: ['index.ts'],
|
||||
bundle: true,
|
||||
format: 'esm',
|
||||
plugins: [
|
||||
alias({
|
||||
stream: require.resolve('readable-stream')
|
||||
}),
|
||||
nodeGlobals({buffer: true})
|
||||
})
|
||||
],
|
||||
define: {
|
||||
window: 'self',
|
||||
global: 'self'
|
||||
},
|
||||
loader: {'.js': 'jsx'}
|
||||
sourcemap: 'external'
|
||||
}
|
||||
|
||||
esbuild.build(buildOptions).then(() => console.log('build success.'))
|
||||
esbuild
|
||||
.build({...common, outdir: 'esm/', format: 'esm', packages: 'external'})
|
||||
.then(() => console.log('esm build success.'))
|
||||
|
||||
esbuild
|
||||
.build({...common, outdir: 'cjs/', format: 'cjs', packages: 'external'})
|
||||
.then(() => console.log('cjs build success.'))
|
||||
|
||||
esbuild
|
||||
.build({
|
||||
...common,
|
||||
outdir: 'standalone/',
|
||||
format: 'iife',
|
||||
globalName: 'NostrTools'
|
||||
})
|
||||
.then(() => console.log('standalone build success.'))
|
||||
|
||||
Reference in New Issue
Block a user