Files
core/tsup.config.ts
T
chrnx 9d79972f62 chore(release): dual ESM/CJS build via tsup; fix packaging; 26.07.0-beta.0
Packaging was broken for consumers: `main` resolved to a nonexistent
dist/index.js (tsc emitted dist/src/index.js), and the tarball shipped
tests, benches and sources. Build with tsup to emit CJS + ESM (+ types)
behind an `exports` map so `require` and `import` both resolve; a
createRequire banner keeps the lazy require('ws')/require('busboy') working
under ESM. Add the `files` allowlist and a `prepublishOnly` gate.

Bump to the first CalVer beta, published under the npm `beta` dist-tag.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-07-07 11:59:57 -05:00

23 lines
938 B
TypeScript

import { defineConfig } from 'tsup';
// Dual build: CJS (dist/index.js) + ESM (dist/index.mjs) + type declarations, from one entry.
// tsup injects a createRequire shim into the ESM output so the lazy require('ws') / require('busboy')
// (optional peer deps) keep working there. reflect-metadata and the peer deps stay external.
export default defineConfig({
entry: ['src/index.ts'],
format: ['cjs', 'esm'],
dts: true,
clean: true,
sourcemap: true,
target: 'node18',
// Give the ESM output a real `require` (via createRequire) so the lazy require('ws') / require('busboy')
// (optional peer deps) resolve instead of hitting esbuild's "Dynamic require not supported" stub.
esbuildOptions(options, context) {
if (context.format === 'esm') {
options.banner = {
js: "import { createRequire as _createRequire } from 'node:module'; const require = _createRequire(import.meta.url);",
};
}
},
});