Composite Projects की जानकारी
In this page:
{
"compilerOptions": {
"composite": true,
"declaration": true
}
}
composite Enable करना
composite को किसी project के compilerOptions में true सेट करें जब वह project किसी दूसरे project द्वारा reference किए जाने के लिए meant हो — यह वह flag है जो उस specific tsconfig.json के लिए project-reference behavior unlock करता है।
उदाहरण: Enabling composite
// tsconfig.json
// { "compilerOptions": { "composite": true } }
console.log("composite: true unlocks project-reference behavior for this config");
Composite और Declaration Files
Composite projects को आमतौर पर declaration output on चाहिए ताकि dependent projects original source files तक access चाहे बिना इनके public types देख और इनके against type-check कर सकें।
उदाहरण: Composite and Declaration Files
// tsconfig.json
// { "compilerOptions": { "composite": true, "declaration": true } }
console.log("Composite projects need declaration output for dependents to use");
Composite और rootDir
एक composite project के पास एक normal project से stricter source-file requirements होती हैं, तो एक clear rootDir define करना इसके output structure को किसी भी project के लिए जो इसे reference करता है उसके लिए predictable रखता है।
उदाहरण: Composite and rootDir
// tsconfig.json
// { "compilerOptions": { "composite": true, "rootDir": "src" } }
console.log("A clear rootDir keeps composite project output structure predictable");
References वाले Composite
Composite projects एक project-reference graph के building blocks हैं — हर एक एक self-contained unit है जिसे दूसरे projects अपने ही tsconfig.json में references array के through point कर सकते हैं।
उदाहरण: Composite with References
// consumer/tsconfig.json
// { "references": [{ "path": "../composite-lib" }] }
console.log("Composite projects are the buildable units other projects reference");
Incremental Builds
Composite projects TypeScript की incremental build information के साथ naturally काम करते हैं, tsc -b को उन projects को rebuild करना skip करने देते हुए जिनका source पिछले build के बाद नहीं बदला, जो बड़े monorepos में काफी speed up करता है।
उदाहरण: Incremental Builds
// tsc -b (skips projects whose source hasn't changed)
console.log("Composite projects enable fast incremental builds in monorepos");
declarationके बिनाcompositeon करना, याincludeसे files छोड़ना, जो files list न होने के बारे में errors का कारण बनता है।rootDirगलत सेट करना ताकि इसके बाहर की files compile error का कारण बनें।- No references वाले एक standalone project में
compositeउपयोगी होने की उम्मीद करना।
Chapter Quiz — Complete all 7 topics to unlock
0/7 topics done
Complete these topics first: