Build
tspub uses esbuild under the hood for fast, zero-config builds.
Quick Start
bash
tspub buildThis outputs ESM + type declarations to dist/.
What Gets Built
- ESM (
.js) — default output format - CJS (
.cjs) — opt-in withformats: ["esm", "cjs"] - Type declarations (
.d.ts) — generated automatically - Sourcemaps — opt-in with
sourcemap: true
Entry Detection
tspub auto-detects your entry point from package.json:
exports["."].import→ uses that path's source equivalentmainfield → uses that- Falls back to
src/index.ts
Or specify explicitly:
bash
tspub build --entry src/index.tsNamed Entries
For multiple entry points, use named entries:
typescript
export default {
build: {
entry: {
index: "src/index.ts",
cli: "src/cli.ts",
worker: "src/worker.ts",
},
},
};Or via CLI:
bash
tspub build --entry "index=src/index.ts,cli=src/cli.ts"Named entries produce matching output filenames (dist/index.js, dist/cli.js, etc.).
Auto-Splitting
When building multiple entry points as ESM, code splitting is automatically enabled. Shared code between entries is extracted into separate chunks to avoid duplication. You can override this with splitting: false.
Output
dist/
├── index.js # ESM
├── index.d.ts # Type declarations
├── index.cjs # CJS (if enabled)
└── index.d.cts # CJS declarations (if enabled)