Incremental Compilation की जानकारी
In this page:
{
"compilerOptions": {
"incremental": true,
"tsBuildInfoFile": "./.tsbuildinfo"
}
}
Core Concept
Incremental compilation tsc से एक .tsbuildinfo file save करवाता है जो record करती है कि कौन सी files check हुई थीं और वे किस पर depend करती हैं, इसलिए एक बाद का compile scratch से पूरे project के बजाय सिर्फ उन files को re-check करता है जो असल में बदली।
उदाहरण: Core Concept
// tsconfig.json: { "compilerOptions": { "incremental": true } }
// Produces a .tsbuildinfo file tracking what's already been checked.
console.log("Incremental builds only re-check files that actually changed");
Basic Setup
इसे enable करना एक single tsconfig.json flag है: "incremental": true (या यह automatically implied होता है जब project references के लिए "composite": true set हो)।
उदाहरण: Basic Setup
// tsconfig.json
// { "compilerOptions": { "incremental": true, "tsBuildInfoFile": "./.tsbuildinfo" } }
console.log("A single flag enables incremental compilation");
Typed Example
एक typed example: एक बड़े project पर, पहला tsc run 20 seconds ले सकता है, लेकिन एक file edit करने के बाद दूसरा run एक second से कम में complete होता है, क्योंकि सिर्फ वह file और इसके dependents re-type-check होते हैं।
उदाहरण: Typed Example
// First tsc run: 20s. Edit one file, run again: under 1s.
console.log("Only the changed file and its dependents get re-checked");
Project Usage
एक असली project में, incremental compilation को watch mode (tsc --watch) के साथ combine करना वह है जो एक बड़े codebase के edit-save-recheck loop को हर keystroke के बाद multi-second wait force करने के बजाय instant feel कराता है।
उदाहरण: Project Usage
// tsc --watch + incremental: true makes the edit-save loop feel instant
console.log("Watch mode plus incremental builds speeds up large codebases");
Best Practices
.tsbuildinfo को version control में commit करें सिर्फ तब अगर आपका CI setup इसे runs के बीच reliably restore कर सके; नहीं तो इसे git से exclude करें और हर fresh CI run को one-time full-compile cost pay होने दें।
उदाहरण: Best Practices
// .gitignore: .tsbuildinfo (unless CI can reliably cache it)
console.log("Only commit .tsbuildinfo if your CI can restore it between runs");
.tsbuildinfofile delete करना या commit करना, इसलिए incremental builds फिर से शुरू होते हैं या stale data उपयोग करते हैं।- यह उम्मीद करना कि
incrementalपहले build को तेज़ करेगा, जब सिर्फ बाद के builds को फायदा होता है। --noEmitकोincrementalके साथ उपयोग करना बिनाtsBuildInfoFileset किए, उन versions में जहां इसकी ज़रूरत है।
Chapter Quiz — Complete all 5 topics to unlock
0/5 topics done
Complete these topics first: