Skip to content

Configuration Reference ​

tspub is zero-config by default. For customization, create tspub.config.ts in your project root.

Config File ​

typescript
import type { TspubConfig } from "tspub";

export default {
  // options
} satisfies TspubConfig;

Also supports: tspub.config.js, tspub.config.mjs, or a "tspub" key in package.json.

Build Options ​

typescript
interface TspubBuildConfig {
  formats?: ("esm" | "cjs" | "iife")[];
  entry?: string | string[] | Record<string, string>;
  outDir?: string;
  clean?: boolean;
  dts?: boolean;
  dtsBundle?: boolean;
  dtsResolve?: boolean;
  sourcemap?: boolean;
  minify?: boolean;
  splitting?: boolean;
  target?: string;
  platform?: "node" | "browser" | "neutral";
  external?: (string | RegExp)[];
  noExternal?: string[];
  define?: Record<string, string>;
  banner?: { js?: string };
  footer?: { js?: string };
  cjsInterop?: boolean;
  esbuildPlugins?: EsbuildPlugin[];
  loader?: Record<string, Loader>;
  replaceNodeEnv?: boolean;
  globalName?: string;
  onSuccess?: string | (() => void | Promise<void>);
  treeshake?: boolean | { ignoreAnnotations?: boolean };
  publicDir?: string;
  inject?: string[];
  sizeLimits?: Record<string, string>;
  shims?: boolean;
}
OptionTypeDefaultDescription
formats("esm" | "cjs" | "iife")[]["esm"]Output module formats
entrystring | string[] | Record<string, string>autoEntry point files
outDirstring"dist"Output directory
cleanbooleantrueClean output before build
dtsbooleantrueGenerate type declarations
dtsBundlebooleanfalseBundle .d.ts into single-file declarations
dtsResolvebooleanfalseResolve external types into bundled .d.ts
sourcemapbooleanfalseGenerate sourcemaps
minifybooleanfalseMinify output
splittingbooleanfalseEnable code splitting (ESM only, auto-enabled for multi-entry)
targetstring—esbuild target (e.g. "es2022", "node18")
platform"node" | "browser" | "neutral"—Target platform
external(string | RegExp)[]—Packages to exclude from bundle
noExternalstring[]—Force-bundle specific packages
defineRecord<string, string>—Compile-time constants
banner{ js?: string }—Prepend text to output files
footer{ js?: string }—Append text to output files
cjsInteropbooleantrueEnable CJS interop (consumers don't need .default)
esbuildPluginsPlugin[]—Pass esbuild plugins directly
loaderRecord<string, Loader>—Custom esbuild loaders by extension
replaceNodeEnvboolean—Replace process.env.NODE_ENV (auto when minify is true). Replaces deprecated envProduction
globalNamestring—Global variable name for IIFE builds
onSuccessstring | () => void—Run command/callback after successful build
treeshakeboolean | object—Esbuild treeshake configuration
publicDirstring—Copy static assets to outDir
injectstring[]—Files to inject into all bundles
sizeLimitsRecord<string, string>—Size budgets — fail build if exceeded
shimsbooleantrueInject __dirname/__filename/import.meta.url shims into CJS

Check Options ​

typescript
interface TspubCheckConfig {
  severityOverrides?: Record<string, "error" | "warning" | "info" | "off">;
  plugins?: string[];
  typeTests?: {
    enabled?: boolean;
    directory?: string;
  };
}
OptionTypeDefaultDescription
severityOverridesRecord<string, Severity | "off">{}Override rule severities
pluginsstring[][]Plugin module paths
typeTests.enabledbooleanfalseRun type tests during check
typeTests.directorystring"test-d"Directory for .test-d.ts files

Publish Options ​

typescript
interface TspubPublishConfig {
  registry?: string;
  access?: "public" | "restricted";
  provenance?: boolean;
  branch?: string | string[];
  changelogStyle?: "simple" | "conventional" | "auto";
  ci?: {
    enabled?: boolean;
    skipPush?: boolean;
  };
  github?: {
    release?: boolean;
    draft?: boolean;
    assets?: string[];
  };
  hooks?: {
    beforeBuild?: string;
    afterBuild?: string;
    beforePublish?: string;
    afterPublish?: string;
  };
}
OptionTypeDefaultDescription
registrystringnpm defaultnpm registry URL
access"public" | "restricted"npm defaultPackage access level
provenancebooleanfalseEnable npm provenance
branchstring | string[]anyAllowed publish branches
changelogStylestring"simple"Changelog format
ci.enabledbooleanfalseCI mode (no prompts)
ci.skipPushbooleanfalseSkip git push
github.releasebooleanfalseCreate GitHub release on publish
github.draftbooleanfalseCreate as draft release
github.assetsstring[]—Files to attach to GitHub release
hooks.beforeBuildstring—Shell command to run before build
hooks.afterBuildstring—Shell command to run after build
hooks.beforePublishstring—Shell command to run before npm publish
hooks.afterPublishstring—Shell command to run after npm publish

Changeset Options ​

typescript
interface TspubChangesetConfig {
  dependentBumping?: "major" | "all" | "none";
  snapshotTag?: string;
  linked?: string[][];
  fixed?: string[][];
}
OptionTypeDefaultDescription
dependentBumpingstring"major"When to bump dependents
snapshotTagstring"snapshot"Tag for snapshot releases
linkedstring[][]—Groups of packages that bump together (highest bump wins)
fixedstring[][]—Groups of packages that always share the same version

Doctor Options ​

typescript
interface TspubDoctorConfig {
  severityOverrides?: Record<string, DoctorSeverity | "off">;
  plugins?: string[];
  profile?: string;
}

Scan Options ​

typescript
interface TspubScanConfig {
  concurrency?: number;
  severityOverrides?: Record<string, Severity | "off">;
  profile?: string;
}

Workspace Inheritance ​

In monorepos, workspace packages inherit the root tspub.config.ts. Package-level configs override root settings.

Released under the MIT License.