monorepo-typescript-references
v1.1.1
Published
A CLI tool to update tsconfig.json references based on your monorepo structure
Maintainers
Readme
monorepo-typescript-references
A CLI tool to automatically manage TypeScript project references in monorepo projects.
Installation
# npm
npm install monorepo-typescript-references
# yarn
yarn add monorepo-typescript-references
# pnpm
pnpm add monorepo-typescript-referencesUsage
# Check if tsconfig references are up-to-date
monorepo-typescript-references check
# Update tsconfig references across the monorepo
monorepo-typescript-references fixOptions
--configName: Specify the name of the tsconfig file in each package (default:tsconfig.json)--rootConfigName: Specify the name of the tsconfig file in the monorepo root (default:tsconfig.json)
How It Works
Consider a monorepo with the following structure:
my-monorepo/
├── apps/
│ └── my-app/
│ ├── package.json # depends on @my-org/pkg-1 and @my-org/pkg-2
│ └── tsconfig.json
├── packages/
│ ├── pkg-1/
│ │ ├── package.json # depends on @my-org/pkg-2
│ │ └── tsconfig.json
│ └── pkg-2/
│ ├── package.json
│ └── tsconfig.json
└── package.jsonWhen you run monorepo-typescript-references fix, it will update the tsconfig.json files to ensure proper TypeScript project references:
// apps/my-app/tsconfig.json
{
"compilerOptions": {
"composite": true,
"outDir": "./dist"
},
+ "references": [
+ { "path": "../../packages/pkg-1/tsconfig.json" }
+ { "path": "../../packages/pkg-2/tsconfig.json" }
+ ]
}// packages/pkg-1/tsconfig.json
{
"compilerOptions": {
"composite": true,
"outDir": "./dist"
},
+ "references": [
+ { "path": "../pkg-2/tsconfig.json" }
+ ]
}This ensures TypeScript compiles the packages in the correct order based on the dependency graph.
Similar Projects
nxprovides built-in support for managing TypeScript project references in monorepo projects. See their documentation for more details.
License
MIT
