Skip to content

Modern projen constructs for TypeScript monorepos: pnpm, NX, ESM, Vitest, oxlint

License

Notifications You must be signed in to change notification settings

kennyg/projen-constructs

Repository files navigation

Projen Constructs

Build

Reusable projen constructs for modern TypeScript monorepos.

Features

  • pnpm workspaces - Efficient dependency management with workspace protocol
  • NX - Build orchestration with caching and affected commands
  • ESM-first - Native ES modules, no CommonJS legacy
  • Vitest - Fast, ESM-native testing
  • oxlint - Rust-powered linting (50-100x faster than ESLint)
  • Bun - Fast TypeScript execution for projenrc

Quick Start

Installation

pnpm add -D "github:kennyg/projen-constructs#path:packages/projen-constructs"

Usage

import { typescript, javascript } from 'projen';
import { PnpmWorkspace, Nx, Vitest, Oxlint, VscodeSettings } from '@kennyg/projen-constructs';

const project = new typescript.TypeScriptProject({
  name: 'my-monorepo',
  defaultReleaseBranch: 'main',
  packageManager: javascript.NodePackageManager.PNPM,
  projenrcTs: true,
});

// Add monorepo tooling
new PnpmWorkspace(project);
new Nx(project);
new VscodeSettings(project);

// Create a subproject with modern tooling
const myLib = new typescript.TypeScriptProject({
  parent: project,
  outdir: 'packages/my-lib',
  name: '@my-scope/my-lib',
  // ...
});

new Vitest(myLib);
new Oxlint(myLib);

project.synth();

Available Constructs

Construct Description
PnpmWorkspace Generates pnpm-workspace.yaml from subprojects
Nx Configures NX for build orchestration and caching
Vitest Adds Vitest testing with coverage support
Oxlint Adds oxlint linting with auto-fix
VscodeSettings Configures VS Code for monorepo development

Repository Structure

projen-constructs/
├── packages/
│   └── projen-constructs/    # The publishable construct library
├── examples/
│   ├── shared-lib/           # Example shared library
│   └── app-a/                # Example app using shared-lib
├── projenrc/
│   └── mise.ts               # Local components (not yet published)
└── docs/
    └── architecture.md       # Detailed architecture documentation

Development

# Install dependencies
pnpm install

# Regenerate project files
bun .projenrc.ts

# Build all packages
pnpm nx run-many -t build

# Test all packages
pnpm nx run-many -t test

# Lint all packages
pnpm nx run-many -t lint

Documentation

See docs/architecture.md for detailed information about:

  • Design decisions and rationale
  • How each construct works
  • Adding new packages to the monorepo
  • Tool version management with mise

License

Apache-2.0

About

Modern projen constructs for TypeScript monorepos: pnpm, NX, ESM, Vitest, oxlint

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •