RepoFold

Project Configuration

This page documents the development toolchain and configuration files located in the root module of the ms repository. It covers the build system, testing framework, linting and formatting tools, and the scripts that orchestrate them. Contributors should read this page alongside Contributing for the full development workflow.

Repository Layout

The root module ("") contains only configuration files. All library source code lives in the src module. The three configuration files at the project root are:

FilePurpose
jest.config.tsJest test runner configuration
lint-staged.config.tsLint-staged configuration for pre-commit hooks
tsdown.config.tsBuild bundler configuration

Build Tool

The library uses tsdown as its build tool. The configuration file tsdown.config.ts (located at the project root) defines how the TypeScript source in src is compiled and bundled into distributable output. The build process is triggered by the build script in package.json:

pnpm build

This command produces the compiled package that consumers install from npm. The build is also run automatically in the release workflow (.github/workflows/release.yml) before publishing.

Testing

Test Runner

The project uses Jest as its test runner, configured in jest.config.ts at the project root. There are two test suites defined in package.json:

ScriptCommandPurpose
test:nodejspnpm test:nodejsRuns tests in a Node.js environment
test:edgepnpm test:edgeRuns tests in an Edge Runtime environment

Running Tests

To run all tests locally:

pnpm test:nodejs
pnpm test:edge

The CI workflow .github/workflows/test.yml runs both test suites across three Node.js versions (20, 22, 24) on every push to main and on pull requests targeting main. The matrix strategy ensures compatibility across supported Node.js releases .github/workflows/test.yml:13-16.

Linting and Formatting

Linting

The project uses a linter configured through the lint script in package.json. Run it with:

pnpm lint

The CI quality workflow (.github/workflows/quality.yml) runs linting as one of its matrix tasks on every push to main and on pull requests .github/workflows/quality.yml:11-13.

Formatting

Code formatting is managed through a formatter configured via the format script:

pnpm format

The quality workflow also runs formatting checks as a separate matrix task .github/workflows/quality.yml:11-13.

Pre-commit Hooks

The project uses lint-staged (configured in lint-staged.config.ts) to run linters and formatters on staged files before commits. The precommit script in package.json triggers lint-staged:

pnpm precommit

This ensures that only properly formatted and lint-free code enters the repository. The prepare script in package.json likely sets up the git hooks automatically on pnpm install.

Type Checking

TypeScript type checking is performed via the typecheck script:

pnpm typecheck

This script runs the TypeScript compiler in type-checking mode (without emitting output) to verify that the codebase has no type errors. The quality workflow includes typecheck as a matrix task .github/workflows/quality.yml:11-13.

Additional Quality Checks

The project also runs attw (Are The Types Wrong) as part of the quality workflow .github/workflows/quality.yml:11-13. This tool validates that the package's TypeScript type definitions are correctly exported and consumable by consumers. Run it with:

pnpm attw

CI Workflows

Three GitHub Actions workflows automate the development pipeline:

Quality Workflow (.github/workflows/quality.yml)

  • Triggered on push to main and pull requests targeting main
  • Runs four tasks in parallel: format, lint, typecheck, attw
  • Uses Node.js 24 and pnpm .github/workflows/quality.yml:1-29

Test Workflow (.github/workflows/test.yml)

  • Triggered on push to main and pull requests targeting main
  • Runs test:nodejs and test:edge across Node.js 20, 22, and 24
  • Uses a matrix strategy with fail-fast: false to report all failures .github/workflows/test.yml:1-33

Release Workflow (.github/workflows/release.yml)

  • Triggered only on push to main
  • Builds the package and publishes a nightly canary release to npm under the nightly tag
  • Uses npm provenance for supply chain security (NPM_CONFIG_PROVENANCE: 'true') .github/workflows/release.yml:1-43

Development Workflow Summary

For contributors, the typical development cycle is:

  1. Install dependencies: pnpm install
  2. Make changes in the src module
  3. Run type checking: pnpm typecheck
  4. Run linting: pnpm lint
  5. Run formatting: pnpm format
  6. Run tests: pnpm test:nodejs and pnpm test:edge
  7. Build the package: pnpm build
  8. Commit changes (pre-commit hooks run automatically via lint-staged)

All of these checks are enforced in CI on pull requests, so running them locally before pushing saves iteration time.

Generated from commit 4ff48ce