Template-driven configuration management for TypeScript projects and monorepos
β’β βQuick Startβ ββ’β βMonorepo Structureβ ββ’β βOfficial Presetsβ ββ’β βUsageβ ββ’
Presetter helps maintainers ship shared TypeScript toolchain configuration across many repos and monorepo packages. Instead of hand-copying ESLint, Vitest, TypeScript, build, and script setup into every project, you describe the stack in presetter.config.ts, compose official presets, and regenerate the output files your toolchain expects.
This monorepo contains the Presetter engine and a comprehensive ecosystem of official presets for every TypeScript development scenario.
Every repo starts clean. Then the same eslint, vitest, typescript, build, and lifecycle settings fork in small ways across apps, packages, services, and CLIs.
Presetter moves that intent into presetter.config.ts: compose official presets for the shared baseline, keep local overrides visible, and regenerate the config files your toolchain still expects.
overview.mp4
# Before: copied config across repos and packages
workspace/
βββ apps/web/eslint.config.ts β React-specific edits
βββ apps/api/eslint.config.ts β Similar, but not quite the same
βββ packages/ui/vitest.config.ts β Local test tweaks
βββ packages/core/tsconfig.json β Shared intent copied by hand
βββ packages/runtime/package.json β Scripts slowly drift
# After: explicit preset stack plus generated outputs
workspace/
+βββ presetter.config.ts β Compose the maintained baseline
βββ package.json β Scripts merge with preset scripts
βββ generated config files β Output files can stay out of Git# π’ Modern ESM development
npm install --save-dev presetter @presetter/preset-esm
# π Legacy CommonJS compatibility
npm install --save-dev presetter @presetter/preset-cjs
# π Dual-module library publishing
npm install --save-dev presetter @presetter/preset-hybrid
# π© Node.js runtime
npm install --save-dev presetter @presetter/preset-esm @presetter/preset-node
# π₯ Bun runtime
npm install --save-dev presetter @presetter/preset-bun
# π¨ Modern web development (TailwindCSS)
npm install --save-dev presetter @presetter/preset-esm @presetter/preset-web
# π Storybook for Next.js development
npm install --save-dev presetter @presetter/preset-next @presetter/preset-storybook
# βοΈ React application with optimized toolchain
npm install --save-dev presetter @presetter/preset-esm @presetter/preset-react
# π’ Production-grade (security + 100% coverage)
npm install --save-dev presetter @presetter/preset-esm @presetter/preset-strict
# β‘ Next.js application with full-stack support
npm install --save-dev presetter @presetter/preset-next- Add Presetter and preset to your project:
{
scripts: {
bootstrap: 'presetter bootstrap',
},
devDependencies: {
'presetter': 'latest',
'@presetter/preset-esm': 'latest',
},
}- Create preset configuration:
// presetter.config.ts
export { default } from '@presetter/preset-esm';- Install and start developing:
npm install
npm run bootstrap # Generate project configs from your preset stack
npm run test # Run through the maintained toolchainThis repository is organized as a TypeScript monorepo containing the core Presetter engine and all official presets:
presetter/
βββ packages/
β βββ presetter/ ποΈ Core engine
β βββ types/ π TypeScript definitions
β
βββ presets/
β βββ essentials/ ποΈ Foundation toolkit
β βββ monorepo/ π¦ Monorepo management
β β
β βββ esm/ π ESM-first
β βββ cjs/ π CommonJS
β βββ hybrid/ π Dual CJS/ESM
β βββ bun/ π₯ Bun runtime
β βββ node/ π© Node.js runtime
β β
β βββ strict/ π’ Production-grade quality
β βββ web/ π¨ Web dev stack
β βββ storybook/ π Storybook
β βββ react/ βοΈ React
β βββ next/ β‘ Next.js
β βββ rollup/ π¦ Library bundling
β
βββ website/ π Docusaurus documentation site
βββ e2e/ π§ͺ End-to-end integration tests
βββ examples/ π¬ Example consumer projects
βββ assets/ π¨ Logos and demo assets
| Category | Packages | Purpose |
|---|---|---|
| Core Engine | presetter, @presetter/types |
Configuration management infrastructure |
| Foundation | @presetter/preset-essentials, @presetter/preset-monorepo |
Base TypeScript development toolkit |
| Module Systems | @presetter/preset-esm, @presetter/preset-cjs, @presetter/preset-hybrid |
JavaScript module format specializations |
| Runtimes | @presetter/preset-node, @presetter/preset-bun |
Runtime-specific TypeScript and build settings |
| Extensions | @presetter/preset-strict, @presetter/preset-web, @presetter/preset-storybook, @presetter/preset-react, @presetter/preset-rollup |
Specialized development environments |
| Frameworks | @presetter/preset-next |
Framework-specific preset composition |
| Preset | Purpose | Dependencies | Best For |
|---|---|---|---|
| @presetter/preset-essentials | Complete TypeScript development toolkit | TypeScript, ESLint, Vitest, Prettier, Husky | Foundation for all TypeScript projects |
| @presetter/preset-monorepo | Monorepo project management | Workspace tools, cross-package scripts | Multi-package repositories |
| Preset | Purpose | Extends | Best For |
|---|---|---|---|
| @presetter/preset-esm | ESM-first development | essentials | Modern Node.js projects, libraries |
| @presetter/preset-cjs | CommonJS compatibility | essentials | Legacy environments, enterprise |
| @presetter/preset-hybrid | Dual CommonJS/ESM packages | essentials | npm libraries needing broad compatibility |
| @presetter/preset-bun | Bun runtime and build flow | none | Bun applications, CLIs, services |
| @presetter/preset-node | Node.js runtime types | none | Node.js apps, CLIs, services |
| Preset | Purpose | Extends | Best For |
|---|---|---|---|
| @presetter/preset-strict | Production-grade quality enforcement | Any base preset | Enterprise applications, critical systems |
| @presetter/preset-web | Browser globals and Tailwind linting | Any base preset | Web applications, SPAs |
| @presetter/preset-storybook | Storybook component workflow | Any UI preset | Component development and interaction tests |
| @presetter/preset-react | React and TSX tooling | none | React applications, component libraries |
| @presetter/preset-next | Next.js full-stack development | esm + node + strict + web + react | Next.js apps with App Router, Server Components |
| @presetter/preset-rollup | Professional library bundling | none | npm packages, open-source libraries |
// Modern web application
extends: [esm, web]
// Next.js with Storybook
extends: [next, storybook]
// Bun application
extends: [esm, bun]
// Node.js service
extends: [esm, node]
// React component library
extends: [react, rollup]
// Legacy Node.js service
extends: [cjs]
// Full-stack TypeScript monorepo
extends: [monorepo]
// Next.js application (includes everything)
export { default } from '@presetter/preset-next';Presetter transforms configuration management through intelligent template processing:
ποΈ The Core Engine (packages/presetter)
Presetter handles two main responsibilities:
-
ποΈ Environment Setup:
- Resolves the configured preset graph
- Generates configuration files using sophisticated templates
- Relies on package managers to install preset peer dependencies
-
β‘ Script Management:
- Merges preset scripts with local
package.jsonscripts - Provides intelligent script composition and execution
- Enables
run,run-s, andrun-pcommands for enhanced workflows - Binary Path Resolution: Discovers executables in each preset's
node_modules/.binand prepends them to PATH, allowing preset tools to take priority without requiringshamefullyHoistorpublic-hoist-patternconfiguration
Note: Libraries loaded via dynamic import (like
@vitest/coverage-v8) may still need to be installed at root or hoisted. See the presetter package docs for details. - Merges preset scripts with local
Each preset is a reusable configuration bundle containing:
- Dependencies: Defined as
peerDependenciesand installed during bootstrap - Configuration Templates: Dynamic files that adapt to your project structure
- Scripts: Lifecycle commands that integrate with your local workflows
- Variables: Customizable parameters for flexible configuration
Presetter uses a sophisticated resolution process:
- π Dependency Resolution: Build preset inheritance tree and merge configurations
- π― Asset Generation: Process templates with context-aware variable substitution
- β‘ Override Application: Apply customizations while preserving preset benefits
Want the full diagrammed walkthrough? See ARCHITECTURE.md.
// presetter.config.ts - Use a preset as-is
export { default } from '@presetter/preset-esm';// presetter.config.ts - Customize and extend presets
import { preset } from 'presetter';
import esm from '@presetter/preset-esm';
import strict from '@presetter/preset-strict';
export default preset('my-project', {
extends: [esm, strict],
override: {
variables: {
target: 'ES2023', // Modern compilation target
source: 'source', // Custom source directory
},
assets: {
'tsconfig.json': {
compilerOptions: {
allowImportingTsExtensions: true,
},
},
},
},
});# Configuration generation
presetter bootstrap # Apply configurations
presetter bootstrap --projects "packages/*" # Bootstrap project path globs
presetter bootstrap --packages "@scope/*" # Bootstrap package-name globs
# Development workflows
run build # Build your project
run test # Run tests with coverage
run lint # Lint and fix code
run watch # Development mode
# Advanced execution
run-s clean build test # Sequential execution
run-p lint test # Parallel executionThis monorepo uses Presetter itself for development! Each package has its own preset configuration:
# Install dependencies
npm install
# Bootstrap all packages
npm run bootstrap
# Run tests across all packages
npm run test
# Build all packages
npm run buildgraph TD
T[types]
P[presetter]
E[preset-essentials]
S[preset-strict]
M[preset-esm]
C[preset-cjs]
H[preset-hybrid]
B[preset-bun]
N[preset-node]
W[preset-web]
R[preset-react]
X[preset-next]
U[preset-rollup]
O[preset-monorepo]
P --> T
E --> T
M --> E
C --> E
H --> E
S --> T
W --> T
R --> W
X --> M
X --> S
X --> R
U --> T
O --> M
O --> S
The monorepo provides convenient workspace-wide commands:
| Command | Purpose |
|---|---|
npm run build |
Build all packages in dependency order |
npm run test |
Run tests across all packages |
npm run lint |
Lint all packages with auto-fix |
npm run clean |
Clean build artifacts |
npm run bootstrap |
Bootstrap all preset configurations |
Each package contains comprehensive documentation:
- Core Engine Documentation - CLI usage, configuration, advanced features
- Preset Development Guide - TypeScript definitions and preset creation
- Individual Preset Guides - Detailed feature explanations and usage examples
| Topic | Resource |
|---|---|
| Getting Started | Core Engine Quick Start |
| Preset Creation | Types Package Guide |
| Advanced Usage | Configuration Customization |
| Monorepo Setup | Monorepo Preset Guide |
We'd love your ideas and contributions! Submit issues or suggestions via GitHub Issues. See the Contribution Guide for more details.
Create a TypeScript file that exports a preset configuration:
import { preset } from 'presetter';
export default preset('my-preset', {
variables: {
source: 'src',
output: 'dist',
},
scripts: {
build: 'tsc',
test: 'vitest',
},
assets: {
'tsconfig.json': {
compilerOptions: {
target: 'ES2024',
module: 'ESNext',
},
},
},
});Use the override field to modify preset configurations:
import { preset } from 'presetter';
import esm from '@presetter/preset-esm';
export default preset('custom', {
extends: [esm],
override: {
assets: {
'tsconfig.json': {
compilerOptions: {
strict: false, // Relax TypeScript strictness
},
},
},
},
});Yes! Presets are designed to be composable:
import { preset } from 'presetter';
import essentials from '@presetter/preset-essentials';
import web from '@presetter/preset-web';
import react from '@presetter/preset-react';
import strict from '@presetter/preset-strict';
export default preset('ultimate-react', {
extends: [essentials, web, react, strict],
});Override the asset with null:
export default preset('custom', {
extends: [somePreset],
override: {
assets: {
'.gitignore': null, // Don't generate .gitignore
},
},
});Override the generated .storybook/main.ts asset with a local file. Storybook uses the addons field for addon changes and framework for renderer changes:
// presetter.config.ts
import { resolve } from 'node:path';
import next from '@presetter/preset-next';
import storybook from '@presetter/preset-storybook';
import { preset } from 'presetter';
export default preset('custom-next-storybook', {
extends: [next, storybook],
override: {
assets: {
'.storybook/main.ts': resolve(import.meta.dirname, '.storybook/main.ts'),
},
},
});// .storybook/main.ts
import type { StorybookConfig } from 'storybook/internal/types';
const config = {
stories: ['../src/**/*.stories.@(ts|tsx|js|jsx|mdx)'],
addons: ['@storybook/addon-a11y', '@storybook/addon-vitest'],
framework: {
name: '@storybook/nextjs-vite',
options: {},
},
} satisfies StorybookConfig;
export default config;Presetter was born from the frustration of maintaining identical configurations across multiple TypeScript projects. The core principles:
- π― Simplicity: One command should set up a complete development environment
- π Maintainability: Updates should propagate across projects through shared preset versions
- π§© Composability: Presets should work together seamlessly
- β‘ Flexibility: Local customizations should always be respected
- π Scalability: Should work for individual projects and large monorepos
Released under the MIT License. Β© 2020, Alvis Tang.
ttps://img.shields.io/github/license/alvis/presetter.svg?style=flat-square)](https://github.com/alvis/presetter/blob/main/LICENSE)
