Skip to content

Commit d44c9c3

Browse files
authored
Always build project irrespective of errors in dependency with tsc -b (#58854)
1 parent e834989 commit d44c9c3

17 files changed

+1930
-162
lines changed

src/compiler/diagnosticMessages.json

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5688,14 +5688,6 @@
56885688
"category": "Message",
56895689
"code": 6361
56905690
},
5691-
"Skipping build of project '{0}' because its dependency '{1}' has errors": {
5692-
"category": "Message",
5693-
"code": 6362
5694-
},
5695-
"Project '{0}' can't be built because its dependency '{1}' has errors": {
5696-
"category": "Message",
5697-
"code": 6363
5698-
},
56995691
"Build one or more projects and their dependencies, if out of date": {
57005692
"category": "Message",
57015693
"code": 6364
@@ -5740,14 +5732,6 @@
57405732
"category": "Message",
57415733
"code": 6381
57425734
},
5743-
"Skipping build of project '{0}' because its dependency '{1}' was not built": {
5744-
"category": "Message",
5745-
"code": 6382
5746-
},
5747-
"Project '{0}' can't be built because its dependency '{1}' was not built": {
5748-
"category": "Message",
5749-
"code": 6383
5750-
},
57515735
"Have recompiles in '--incremental' and '--watch' assume that changes within a file will only affect files directly depending on it.": {
57525736
"category": "Message",
57535737
"code": 6384

src/compiler/tsbuild.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ export enum UpToDateStatusType {
2525
OutOfDateOptions,
2626
OutOfDateRoots,
2727
UpstreamOutOfDate,
28-
UpstreamBlocked,
2928
ComputingUpstream,
3029
TsVersionOutputOfDate,
3130
UpToDateWithInputFileText,
@@ -48,7 +47,6 @@ export type UpToDateStatus =
4847
| Status.OutOfDateBuildInfo
4948
| Status.OutOfDateRoots
5049
| Status.UpstreamOutOfDate
51-
| Status.UpstreamBlocked
5250
| Status.ComputingUpstream
5351
| Status.TsVersionOutOfDate
5452
| Status.ContainerOnly
@@ -137,15 +135,6 @@ export namespace Status {
137135
upstreamProjectName: string;
138136
}
139137

140-
/**
141-
* This project depends an upstream project with build errors
142-
*/
143-
export interface UpstreamBlocked {
144-
type: UpToDateStatusType.UpstreamBlocked;
145-
upstreamProjectName: string;
146-
upstreamProjectBlocked: boolean;
147-
}
148-
149138
/**
150139
* Computing status of upstream projects referenced
151140
*/

src/compiler/tsbuildPublic.ts

Lines changed: 3 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1128,18 +1128,18 @@ function createBuildOrUpdateInvalidedProject<T extends BuilderProgram>(
11281128
updateOutputTimestampsWorker(state, config, projectPath, Diagnostics.Updating_unchanged_output_timestamps_of_project_0, emittedOutputs);
11291129
}
11301130
state.projectErrorsReported.set(projectPath, true);
1131+
buildResult = program.hasChangedEmitSignature?.() ? BuildResultFlags.None : BuildResultFlags.DeclarationOutputUnchanged;
11311132
if (!diagnostics.length) {
11321133
state.diagnostics.delete(projectPath);
11331134
state.projectStatus.set(projectPath, {
11341135
type: UpToDateStatusType.UpToDate,
11351136
oldestOutputFileName: firstOrUndefinedIterator(emittedOutputs.values()) ?? getFirstProjectOutput(config, !host.useCaseSensitiveFileNames()),
11361137
});
1137-
buildResult = program.hasChangedEmitSignature?.() ? BuildResultFlags.None : BuildResultFlags.DeclarationOutputUnchanged;
11381138
}
11391139
else {
11401140
state.diagnostics.set(projectPath, diagnostics);
11411141
state.projectStatus.set(projectPath, { type: UpToDateStatusType.Unbuildable, reason: `it had errors` });
1142-
buildResult = BuildResultFlags.AnyErrors;
1142+
buildResult |= BuildResultFlags.AnyErrors;
11431143
}
11441144
afterProgramDone(state, program);
11451145
step = BuildStep.QueueReferencingProjects;
@@ -1256,23 +1256,6 @@ function getNextInvalidatedProjectCreateInfo<T extends BuilderProgram>(
12561256
}
12571257
}
12581258

1259-
if (status.type === UpToDateStatusType.UpstreamBlocked) {
1260-
verboseReportProjectStatus(state, project, status);
1261-
reportAndStoreErrors(state, projectPath, getConfigFileParsingDiagnostics(config));
1262-
projectPendingBuild.delete(projectPath);
1263-
if (options.verbose) {
1264-
reportStatus(
1265-
state,
1266-
status.upstreamProjectBlocked ?
1267-
Diagnostics.Skipping_build_of_project_0_because_its_dependency_1_was_not_built :
1268-
Diagnostics.Skipping_build_of_project_0_because_its_dependency_1_has_errors,
1269-
project,
1270-
status.upstreamProjectName,
1271-
);
1272-
}
1273-
continue;
1274-
}
1275-
12761259
if (status.type === UpToDateStatusType.ContainerOnly) {
12771260
verboseReportProjectStatus(state, project, status);
12781261
reportAndStoreErrors(state, projectPath, getConfigFileParsingDiagnostics(config));
@@ -1474,26 +1457,6 @@ function getUpToDateStatusWorker<T extends BuilderProgram>(state: SolutionBuilde
14741457
continue;
14751458
}
14761459

1477-
// An upstream project is blocked
1478-
if (
1479-
refStatus.type === UpToDateStatusType.Unbuildable ||
1480-
refStatus.type === UpToDateStatusType.UpstreamBlocked
1481-
) {
1482-
return {
1483-
type: UpToDateStatusType.UpstreamBlocked,
1484-
upstreamProjectName: ref.path,
1485-
upstreamProjectBlocked: refStatus.type === UpToDateStatusType.UpstreamBlocked,
1486-
};
1487-
}
1488-
1489-
// If the upstream project is out of date, then so are we (someone shouldn't have asked, though?)
1490-
if (refStatus.type !== UpToDateStatusType.UpToDate) {
1491-
return {
1492-
type: UpToDateStatusType.UpstreamOutOfDate,
1493-
upstreamProjectName: ref.path,
1494-
};
1495-
}
1496-
14971460
if (!force) (referenceStatuses ||= []).push({ ref, refStatus, resolvedRefPath, resolvedConfig });
14981461
}
14991462
}
@@ -1701,7 +1664,7 @@ function getUpToDateStatusWorker<T extends BuilderProgram>(state: SolutionBuilde
17011664
for (const { ref, refStatus, resolvedConfig, resolvedRefPath } of referenceStatuses) {
17021665
// If the upstream project's newest file is older than our oldest output, we
17031666
// can't be out of date because of it
1704-
if (refStatus.newestInputFileTime && refStatus.newestInputFileTime <= oldestOutputFileTime) {
1667+
if ((refStatus as Status.UpToDate).newestInputFileTime && (refStatus as Status.UpToDate).newestInputFileTime! <= oldestOutputFileTime) {
17051668
continue;
17061669
}
17071670

@@ -1867,8 +1830,6 @@ function queueReferencingProjects<T extends BuilderProgram>(
18671830
buildOrder: readonly ResolvedConfigFileName[],
18681831
buildResult: BuildResultFlags,
18691832
) {
1870-
// Queue only if there are no errors
1871-
if (buildResult & BuildResultFlags.AnyErrors) return;
18721833
// Only composite projects can be referenced by other projects
18731834
if (!config.options.composite) return;
18741835
// Always use build order to queue projects
@@ -1904,12 +1865,6 @@ function queueReferencingProjects<T extends BuilderProgram>(
19041865
});
19051866
}
19061867
break;
1907-
1908-
case UpToDateStatusType.UpstreamBlocked:
1909-
if (toResolvedConfigFilePath(state, resolveProjectName(state, status.upstreamProjectName)) === projectPath) {
1910-
clearProjectStatus(state, nextProjectPath);
1911-
}
1912-
break;
19131868
}
19141869
}
19151870
addProjToQueue(state, nextProjectPath, ProgramUpdateLevel.Update);
@@ -2413,15 +2368,6 @@ function reportUpToDateStatus<T extends BuilderProgram>(state: SolutionBuilderSt
24132368
relName(state, configFileName),
24142369
relName(state, status.upstreamProjectName),
24152370
);
2416-
case UpToDateStatusType.UpstreamBlocked:
2417-
return reportStatus(
2418-
state,
2419-
status.upstreamProjectBlocked ?
2420-
Diagnostics.Project_0_can_t_be_built_because_its_dependency_1_was_not_built :
2421-
Diagnostics.Project_0_can_t_be_built_because_its_dependency_1_has_errors,
2422-
relName(state, configFileName),
2423-
relName(state, status.upstreamProjectName),
2424-
);
24252371
case UpToDateStatusType.Unbuildable:
24262372
return reportStatus(
24272373
state,

src/testRunner/unittests/tsbuild/sample.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ describe("unittests:: tsbuild:: on 'sample1' project", () => {
353353
describe("downstream-blocked compilations", () => {
354354
verifyTsc({
355355
scenario: "sample1",
356-
subScenario: "does not build downstream projects if upstream projects have errors",
356+
subScenario: "builds downstream projects even if upstream projects have errors",
357357
fs: () => projFs,
358358
commandLineArgs: ["--b", "tests", "--verbose"],
359359
modifyFs: fs => replaceText(fs, "logic/index.ts", "c.multiply(10, 15)", `c.muitply()`),

src/testRunner/unittests/tsbuildWatch/programUpdates.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,15 @@ createSomeObject().message;`,
300300
caption: "change core",
301301
edit: sys => sys.appendFile("core/index.ts", `\nlet x: string = 10;`),
302302
// Builds core
303+
timeouts: sys => {
304+
sys.runQueuedTimeoutCallbacks();
305+
sys.runQueuedTimeoutCallbacks();
306+
},
307+
},
308+
{
309+
caption: "fix error in logic",
310+
edit: sys => sys.replaceFileText("logic/index.ts", `\nlet y: string = 10;`, ""),
311+
// Builds logic
303312
timeouts: sys => sys.runQueuedTimeoutCallbacks(),
304313
},
305314
],

0 commit comments

Comments
 (0)