Monorepos & Project References
Create a workspace monorepo and wire TypeScript Project References for fast, incremental builds and clean inter-package types.
Monorepos & Project References is a free TypeScript Academy lesson on CoddyKit. This is lesson 1 of 1. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the TypeScript Academy learning path, and your progress syncs across the web and the CoddyKit app. The TypeScript Academy course includes 1 lessons in total.
Intro
Goal: Organize a monorepo that scales. You will declare workspaces, add Project References, and build with tsc -b for incremental output.
- pnpm/yarn workspaces
- Composite projects
- Shared types
Workspace layout
A simple two-package layout: shared (library) and app (depends on shared). Workspaces link local packages.
# folder structure (for reference)
/monorepo
package.json
tsconfig.base.json
packages/
shared/
src/index.ts
package.json
tsconfig.json
app/
src/index.ts
package.json
tsconfig.jsonRoot workspaces
Declare workspaces so the package manager links local deps. Add build/clean scripts using the TS build mode.
// package.json (root)
{
"name": "monorepo",
"private": true,
"workspaces": ["packages/*"],
"scripts": {
"build": "tsc -b packages/*",
"clean": "tsc -b packages/* --clean"
}
}Shared package
Mark the library as a composite project. Emit declarations so dependents can type-check quickly.
// packages/shared/tsconfig.json
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"outDir": "dist",
"rootDir": "src",
"declaration": true,
"composite": true
},
"include": ["src"]
}
// packages/shared/src/index.ts
export interface User { id: string; name: string }
export const hello = (u: User) => `Hello, ${u.name}`App package + refs
Add a references entry to depend on shared. The builder compiles shared first, then app.
// packages/app/tsconfig.json
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"outDir": "dist",
"rootDir": "src",
"composite": true
},
"references": [
{ "path": "../shared" }
],
"include": ["src"]
}
// packages/app/src/index.ts
import { hello } from "shared"
console.log(hello({ id: "u1", name: "Ada" }))Base config & tips
Tips:
- Create
tsconfig.base.jsonfor shared compiler options. - Use
pathsmappings that mirror package names. - Run
tsc -b --watchfor incremental local dev.
References requirement check
Quick check: What must each referenced package include?
Recap
Recap: Workspaces link local packages; Project References (composite + references) unlock fast, incremental tsc -b builds and reliable cross-package types.
Learn TypeScript with an AI tutor — free
Write and run real code in your browser, get instant help from a 24/7 AI tutor, and pick up where you left off on the web or in the app.
- Courses
- 101
- Lessons
- 352
Frequently Asked Questions
Is the “Monorepos & Project References” lesson free?
Yes — the full text of “Monorepos & Project References” is free to read here on the web. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the TypeScript Academy course, upgrade to CoddyKit PRO. The TypeScript Academy course includes 1 lessons in total.
What will I learn in “Monorepos & Project References”?
Create a workspace monorepo and wire TypeScript Project References for fast, incremental builds and clean inter-package types. You practise TypeScript Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start TypeScript Academy?
No prior experience is required. TypeScript Academy on CoddyKit is structured for beginners through advanced learners, so you can start here or from the beginning and move at your own pace. This is lesson 1 of 1.
How long does the “Monorepos & Project References” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this TypeScript Academy lesson?
Yes. Every TypeScript Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.