The Elegant Bundler for Libraries built on Rolldown with TypeScript support, comprehensive plugin ecosystem, and zero-configuration setup
—
Multi-package support for monorepos with filtering and configuration management. Enables building multiple packages in a single command with shared configuration and efficient dependency management.
Interface for configuring workspace behavior in monorepos and multi-package projects.
interface Workspace {
/**
* Workspace directories. Glob patterns are supported.
* - `auto`: Automatically detect `package.json` files in the workspace.
* @default 'auto'
*/
include?: Arrayable<string> | 'auto';
/**
* Exclude directories from workspace.
* Defaults to all `node_modules`, `dist`, `test`, `tests`, `temp`, and `tmp` directories.
*/
exclude?: Arrayable<string>;
/**
* Path to the workspace configuration file.
*/
config?: boolean | string;
}Main workspace configuration options in the build configuration.
interface Options {
/**
* Enable workspace mode for building multiple packages in a monorepo
*/
workspace?: Workspace | Arrayable<string> | true;
/**
* Filter workspace packages. Only available in workspace mode.
*/
filter?: RegExp | string | string[];
}Usage Examples:
import { defineConfig } from "tsdown";
// Enable workspace mode with auto-discovery
export default defineConfig({
workspace: true,
format: ["esm", "cjs"],
dts: true
});
// Workspace with custom include patterns
export default defineConfig({
workspace: {
include: ["packages/*", "apps/*"],
exclude: ["packages/*/test"]
},
format: "esm"
});
// Workspace with string shorthand
export default defineConfig({
workspace: ["packages/*", "tools/*"],
sourcemap: true
});
// Workspace with filtering
export default defineConfig({
workspace: true,
filter: /^@myorg\/.*$/, // Only packages matching pattern
format: ["esm", "cjs"]
});Workspace discovery automatically excludes common directories that shouldn't be treated as packages:
**/node_modules/****/dist/****/test?(s)/****/t?(e)mp/**Command-line interface for workspace operations.
# Enable workspace mode
tsdown --workspace
# Workspace with custom directory
tsdown --workspace packages
# Filter workspace packages
tsdown --workspace --filter @myorg
tsdown --workspace --filter "/ui-.*/"
# Multiple filters
tsdown --workspace --filter "ui,utils"Workspace package discovery process:
package.json files in workspace directoriesDiscovery Examples:
// Auto-discovery (default)
{
workspace: {
include: 'auto' // Finds all package.json files
}
}
// Explicit patterns
{
workspace: {
include: [
"packages/*", // All direct subdirectories in packages/
"apps/*/lib", // Nested lib directories in apps/
"tools/build-*" // Build tools matching pattern
]
}
}
// With exclusions
{
workspace: {
include: "packages/*",
exclude: [
"packages/*/test",
"packages/*/docs",
"packages/legacy-*"
]
}
}Multiple filtering options for targeting specific packages in the workspace.
/**
* Filter patterns for workspace packages
*/
type FilterPattern = RegExp | string | string[];Filter Types:
Filter Examples:
// String filter - matches paths containing "ui"
export default defineConfig({
workspace: true,
filter: "ui"
});
// Regex filter - matches packages starting with @myorg/
export default defineConfig({
workspace: true,
filter: /^@myorg\/.*/
});
// Multiple filters - matches any of the patterns
export default defineConfig({
workspace: true,
filter: ["ui", "utils", "shared"]
});
// Complex regex - matches UI and utility packages
export default defineConfig({
workspace: true,
filter: /\/(ui-|utils-|shared-)/
});Workspace packages inherit configuration from the root with package-specific overrides.
Root Configuration (tsdown.config.ts):
export default defineConfig({
workspace: true,
format: ["esm", "cjs"],
dts: true,
sourcemap: true,
clean: true
});Package-Specific Configuration (packages/ui-lib/tsdown.config.ts):
export default defineConfig({
// Inherits: format, dts, sourcemap, clean from root
entry: "src/index.ts",
external: ["react", "react-dom"], // Package-specific externals
target: "es2020" // Override root target
});Each workspace package can have its own configuration file for package-specific settings.
interface Workspace {
/**
* Path to workspace configuration file
* - `true`: Use default tsdown.config.* files
* - `string`: Use specific configuration file path
* - `false`: Disable workspace configuration files
*/
config?: boolean | string;
}Usage Examples:
// Use default config files in each package
{
workspace: {
include: "packages/*",
config: true
}
}
// Use specific config file name
{
workspace: {
include: "packages/*",
config: "build.config.ts"
}
}
// Disable package-specific configs (root config only)
{
workspace: {
include: "packages/*",
config: false
}
}Workspace builds execute in the following sequence:
Typical Monorepo Structure:
my-monorepo/
├── packages/
│ ├── ui-lib/
│ │ ├── src/index.ts
│ │ ├── package.json
│ │ └── tsdown.config.ts
│ ├── utils/
│ │ ├── src/index.ts
│ │ ├── package.json
│ │ └── tsdown.config.ts
│ └── cli-tool/
│ ├── src/index.ts
│ ├── package.json
│ └── tsdown.config.ts
├── apps/
│ └── web-app/
│ ├── package.json
│ └── (not built with tsdown)
├── tsdown.config.ts (root config)
└── package.jsonConfiguration for Above Structure:
// Root tsdown.config.ts
export default defineConfig({
workspace: {
include: "packages/*", // Only build packages/, not apps/
exclude: ["packages/*/test"]
},
format: ["esm", "cjs"],
dts: true,
clean: true
});Workspace builds handle errors gracefully:
Install with Tessl CLI
npx tessl i tessl/npm-tsdown