Skip to content

Commit

Permalink
[eng/tools] Use TypeScript project references (#31213)
Browse files Browse the repository at this point in the history
- Replaces "postinstall" step in each package, with one in tools folder
- Allows one call to `tsc --build` to compile all projects in the correct dependency order
  • Loading branch information
mikeharder authored and haagha committed Nov 19, 2024
1 parent 0259bce commit e74c944
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 13 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ eng/tools/**/dist
!eng/tools/**/cmd/*.js
!eng/tools/**/eslint.config.js

# TypeScript cache
*.tsbuildinfo

# No package-lock.json files should be commited except the top-level.
**/package-lock.json
!/package-lock.json
Expand Down
4 changes: 4 additions & 0 deletions eng/tools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,9 @@
"@azure-tools/typespec-requirement": "file:typespec-requirement",
"@azure-tools/typespec-validation": "file:typespec-validation"
},
"scripts": {
"build": "tsc --build",
"postinstall": "npm run build"
},
"private": true
}
3 changes: 1 addition & 2 deletions eng/tools/specs-model/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
"get-specs-model": "cmd/get-specs-model.js"
},
"scripts": {
"build": "tsc",
"postinstall": "npm run build",
"build": "tsc --build",
"test": "vitest",
"test:ci": "vitest run --coverage --reporter=verbose",
"lint": "eslint . -c eslint.config.js --report-unused-disable-directives --max-warnings 0",
Expand Down
3 changes: 1 addition & 2 deletions eng/tools/suppressions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
"get-suppressions": "cmd/get-suppressions.js"
},
"scripts": {
"build": "tsc",
"postinstall": "npm run build",
"build": "tsc --build",
"test": "vitest",
"test:ci": "vitest run --coverage --reporter=verbose"
},
Expand Down
14 changes: 12 additions & 2 deletions eng/tools/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@
"module": "Node16",

// override "importHelpers:true" in root tsconfig.json
"importHelpers": false
}
"importHelpers": false,

// required to use project references
"composite": true,
},
"references": [
{ "path": "./specs-model" },
{ "path": "./suppressions" },
{ "path": "./tsp-client-tests" },
{ "path": "./typespec-requirement" },
{ "path": "./typespec-validation" }
]
}
3 changes: 1 addition & 2 deletions eng/tools/tsp-client-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
"vitest": "^2.0.4"
},
"scripts": {
"build": "tsc",
"postinstall": "npm run build",
"build": "tsc --build",
"test": "vitest",
"test:ci": "vitest run --reporter=verbose"
},
Expand Down
3 changes: 1 addition & 2 deletions eng/tools/typespec-requirement/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
"vitest": "^2.0.4"
},
"scripts": {
"build": "tsc",
"postinstall": "npm run build",
"build": "tsc --build",
"test": "vitest",
"test:ci": "vitest run --reporter=verbose"
},
Expand Down
3 changes: 1 addition & 2 deletions eng/tools/typespec-validation/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
"vitest": "^2.0.4"
},
"scripts": {
"build": "tsc",
"postinstall": "cd ../suppressions && npm run build && cd ../typespec-validation && npm run build",
"build": "tsc --build",
"test": "vitest",
"test:ci": "vitest run --coverage --reporter=verbose"
},
Expand Down
5 changes: 4 additions & 1 deletion eng/tools/typespec-validation/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "./dist",
}
},
"references": [
{ "path": "../suppressions" }
]
}

0 comments on commit e74c944

Please sign in to comment.