Terminology (5)Terms used in this lesson
Term on the front, definition on the back. Paste with tabs between fields and a new line between cards, or import the download in Anki as Basic.
- Target
- The program or library a build command is asked to produce.
- Import closure
- A target plus every unit reachable from it through imports, directly or indirectly.
- Dependency-first order
- An order in which every unit comes after all of the units it imports.
- Stale
- Out of date: built from inputs that have since changed.
- tsconfig files / include
- The tsconfig.json fields that choose a TypeScript program’s root files.
A build starts from a target
A build command selects a target, such as an executable, and uses source files, dependency declarations and configuration to produce it. A direct dependency is named by the target; a transitive dependency is reached through another dependency. Together these relationships form a graph that helps explain which inputs belong to the selected work.
Build tools also decide which results they can reuse after an edit. That depends on their compilation units and cache rules: a source module, a package, a crate and a C++ translation unit are not interchangeable build units. We will first reason with an explicit project graph, then compare that model with the actual tool reports.
01Inputs
Which files does the build read?
The shipping team is adding pound support to its parcel quote command. The repository also contains a daily shipped-weight report, and both programs use shared weight constants. Before changing the CI job, establish what building the quote command selects and what a change to those constants requires it to redo.
The quote command is named app. It formats a parcel’s weight and calculates its price, using two helpers that share units. report is a separate program in the same repository. Start with the dependency declarations: does selecting app also select report, and can the build omit units because app never names it directly?
tsconfig.json sets files to ["app.ts"], with no include field; imports add other modules to that program. Removing files without setting include would enable the default file search, including report.ts in this project.
| Unit | Imports | Role |
|---|---|---|
| app | format, rates | The quote command: weight and price for one parcel |
| format | units | Formats parcel weights for quotes |
| rates | units | Prices a parcel by weight |
| report | units | The daily shipped-weight report, a second program |
| units | — | Shared weight constants; weights are stored in grams |
// shipping/app.ts: the quote command; tsconfig.json names this file in "files"
import { kilograms } from "./format.js";
import { priceCents } from "./rates.js";
const parcelGrams = 2500;
console.log(`${kilograms(parcelGrams)}: ${priceCents(parcelGrams)} cents`);
npx tsc -p . --explainFiles --noEmit
The displayed files are excerpts from four complete offline projects with no external dependencies. The commands identify the input/order probes discussed here; the snippets alone are not complete projects. Reports were recorded on 1 November 2026 with Node 22.21, TypeScript 6.0.3, Go 1.27.3, Cargo 1.99.1 and Apple clang 17. No package installation or registry resolution is exercised.
02Order
In which order are units compiled?
The input list puts units under both format and rates. That raises a scheduling question for the CI job: must both helpers wait for units, and does one helper have to wait for the other? A dependency-first plan puts prerequisites before their dependents. To interpret an actual log, first establish what this tool treats as one compilation unit.
format.ts imports units.ts. This project is one TypeScript program, not a set of project references with separately built outputs.
// shipping/format.ts
import { gramsPerKilogram } from "./units.js";
export const kilograms = (grams: number) => `${grams / gramsPerKilogram} kg`;
03Staleness
What does an edit make stale?
The CI input boundary is now clear. Pound support starts by adding an exported conversion constant to units. Both helpers depend on that unit, and app depends on the helpers. Does the quote job need new helper results, or can it reuse them? Compare this change with editing just the pricing helper.
Use a conservative unit model first: mark the edited unit stale, then any unit that depends on a stale result. Continue through the selected target’s closure. This follows dependents toward the target; it does not make the edited unit’s own prerequisites stale. The real tool may reuse results using finer evidence.
units.ts currently holds the gram/kilogram constant. Adding a pound constant changes the input source, even before the helpers start using that new export.
// shipping/units.ts
// Weights are stored in grams.
export const gramsPerKilogram = 1000;
04Practice
Add a CI impact preview
The shipping team wants a reviewable plan for its label-printing job as well as its quote command. Extend a small CI preview that accepts a unit graph, a selected target and an edited unit. It reports direct dependencies, a stable dependency-first plan and the affected units. The preview uses the conservative model taught here; it does not execute builds or reproduce a native cache. Each task supplies the helpers outside its edit.
The CI impact preview
Read the job’s dependencies, produce its plan, then show the effect of an edit.
Sign in to keep your read marks on every device. Sign in
Was this helpful?