Organize build, allow one entrypoint per file (#305)

This commit is contained in:
franzap
2023-10-01 21:20:53 +00:00
committed by GitHub
parent 5e85bbc2ed
commit ce11a5fc89
3 changed files with 149 additions and 12 deletions

View File

@@ -2,9 +2,17 @@
const fs = require('fs')
const esbuild = require('esbuild')
const { join } = require('path');
const entryPoints = fs.readdirSync(process.cwd())
.filter(
(file) =>
file.endsWith(".ts") && !file.endsWith("test.ts") &&
fs.statSync(join(process.cwd(), file)).isFile()
);
let common = {
entryPoints: ['index.ts'],
entryPoints,
bundle: true,
sourcemap: 'external',
}
@@ -12,7 +20,7 @@ let common = {
esbuild
.build({
...common,
outfile: 'lib/esm/nostr.mjs',
outdir: 'lib/esm',
format: 'esm',
packages: 'external',
})
@@ -26,7 +34,7 @@ esbuild
esbuild
.build({
...common,
outfile: 'lib/nostr.cjs.js',
outdir: 'lib/cjs',
format: 'cjs',
packages: 'external',
})
@@ -35,6 +43,7 @@ esbuild
esbuild
.build({
...common,
entryPoints: ['index.ts'],
outfile: 'lib/nostr.bundle.js',
format: 'iife',
globalName: 'NostrTools',