Skip to content

Always build project irrespective of errors in dependency with tsc -b #58854

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 0 additions & 16 deletions src/compiler/diagnosticMessages.json
Original file line number Diff line number Diff line change
Expand Up @@ -5688,14 +5688,6 @@
"category": "Message",
"code": 6361
},
"Skipping build of project '{0}' because its dependency '{1}' has errors": {
"category": "Message",
"code": 6362
},
"Project '{0}' can't be built because its dependency '{1}' has errors": {
"category": "Message",
"code": 6363
},
"Build one or more projects and their dependencies, if out of date": {
"category": "Message",
"code": 6364
Expand Down Expand Up @@ -5740,14 +5732,6 @@
"category": "Message",
"code": 6381
},
"Skipping build of project '{0}' because its dependency '{1}' was not built": {
"category": "Message",
"code": 6382
},
"Project '{0}' can't be built because its dependency '{1}' was not built": {
"category": "Message",
"code": 6383
},
"Have recompiles in '--incremental' and '--watch' assume that changes within a file will only affect files directly depending on it.": {
"category": "Message",
"code": 6384
Expand Down
11 changes: 0 additions & 11 deletions src/compiler/tsbuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ export enum UpToDateStatusType {
OutOfDateOptions,
OutOfDateRoots,
UpstreamOutOfDate,
UpstreamBlocked,
ComputingUpstream,
TsVersionOutputOfDate,
UpToDateWithInputFileText,
Expand All @@ -48,7 +47,6 @@ export type UpToDateStatus =
| Status.OutOfDateBuildInfo
| Status.OutOfDateRoots
| Status.UpstreamOutOfDate
| Status.UpstreamBlocked
| Status.ComputingUpstream
| Status.TsVersionOutOfDate
| Status.ContainerOnly
Expand Down Expand Up @@ -137,15 +135,6 @@ export namespace Status {
upstreamProjectName: string;
}

/**
* This project depends an upstream project with build errors
*/
export interface UpstreamBlocked {
type: UpToDateStatusType.UpstreamBlocked;
upstreamProjectName: string;
upstreamProjectBlocked: boolean;
}

/**
* Computing status of upstream projects referenced
*/
Expand Down
60 changes: 3 additions & 57 deletions src/compiler/tsbuildPublic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1128,18 +1128,18 @@ function createBuildOrUpdateInvalidedProject<T extends BuilderProgram>(
updateOutputTimestampsWorker(state, config, projectPath, Diagnostics.Updating_unchanged_output_timestamps_of_project_0, emittedOutputs);
}
state.projectErrorsReported.set(projectPath, true);
buildResult = program.hasChangedEmitSignature?.() ? BuildResultFlags.None : BuildResultFlags.DeclarationOutputUnchanged;
if (!diagnostics.length) {
state.diagnostics.delete(projectPath);
state.projectStatus.set(projectPath, {
type: UpToDateStatusType.UpToDate,
oldestOutputFileName: firstOrUndefinedIterator(emittedOutputs.values()) ?? getFirstProjectOutput(config, !host.useCaseSensitiveFileNames()),
});
buildResult = program.hasChangedEmitSignature?.() ? BuildResultFlags.None : BuildResultFlags.DeclarationOutputUnchanged;
}
else {
state.diagnostics.set(projectPath, diagnostics);
state.projectStatus.set(projectPath, { type: UpToDateStatusType.Unbuildable, reason: `it had errors` });
buildResult = BuildResultFlags.AnyErrors;
buildResult |= BuildResultFlags.AnyErrors;
}
afterProgramDone(state, program);
step = BuildStep.QueueReferencingProjects;
Expand Down Expand Up @@ -1256,23 +1256,6 @@ function getNextInvalidatedProjectCreateInfo<T extends BuilderProgram>(
}
}

if (status.type === UpToDateStatusType.UpstreamBlocked) {
verboseReportProjectStatus(state, project, status);
reportAndStoreErrors(state, projectPath, getConfigFileParsingDiagnostics(config));
projectPendingBuild.delete(projectPath);
if (options.verbose) {
reportStatus(
state,
status.upstreamProjectBlocked ?
Diagnostics.Skipping_build_of_project_0_because_its_dependency_1_was_not_built :
Diagnostics.Skipping_build_of_project_0_because_its_dependency_1_has_errors,
project,
status.upstreamProjectName,
);
}
continue;
}

if (status.type === UpToDateStatusType.ContainerOnly) {
verboseReportProjectStatus(state, project, status);
reportAndStoreErrors(state, projectPath, getConfigFileParsingDiagnostics(config));
Expand Down Expand Up @@ -1474,26 +1457,6 @@ function getUpToDateStatusWorker<T extends BuilderProgram>(state: SolutionBuilde
continue;
}

// An upstream project is blocked
if (
refStatus.type === UpToDateStatusType.Unbuildable ||
refStatus.type === UpToDateStatusType.UpstreamBlocked
) {
return {
type: UpToDateStatusType.UpstreamBlocked,
upstreamProjectName: ref.path,
upstreamProjectBlocked: refStatus.type === UpToDateStatusType.UpstreamBlocked,
};
}

// If the upstream project is out of date, then so are we (someone shouldn't have asked, though?)
if (refStatus.type !== UpToDateStatusType.UpToDate) {
return {
type: UpToDateStatusType.UpstreamOutOfDate,
upstreamProjectName: ref.path,
};
}

if (!force) (referenceStatuses ||= []).push({ ref, refStatus, resolvedRefPath, resolvedConfig });
}
}
Expand Down Expand Up @@ -1701,7 +1664,7 @@ function getUpToDateStatusWorker<T extends BuilderProgram>(state: SolutionBuilde
for (const { ref, refStatus, resolvedConfig, resolvedRefPath } of referenceStatuses) {
// If the upstream project's newest file is older than our oldest output, we
// can't be out of date because of it
if (refStatus.newestInputFileTime && refStatus.newestInputFileTime <= oldestOutputFileTime) {
if ((refStatus as Status.UpToDate).newestInputFileTime && (refStatus as Status.UpToDate).newestInputFileTime! <= oldestOutputFileTime) {
continue;
}

Expand Down Expand Up @@ -1867,8 +1830,6 @@ function queueReferencingProjects<T extends BuilderProgram>(
buildOrder: readonly ResolvedConfigFileName[],
buildResult: BuildResultFlags,
) {
// Queue only if there are no errors
if (buildResult & BuildResultFlags.AnyErrors) return;
// Only composite projects can be referenced by other projects
if (!config.options.composite) return;
// Always use build order to queue projects
Expand Down Expand Up @@ -1904,12 +1865,6 @@ function queueReferencingProjects<T extends BuilderProgram>(
});
}
break;

case UpToDateStatusType.UpstreamBlocked:
if (toResolvedConfigFilePath(state, resolveProjectName(state, status.upstreamProjectName)) === projectPath) {
clearProjectStatus(state, nextProjectPath);
}
break;
}
}
addProjToQueue(state, nextProjectPath, ProgramUpdateLevel.Update);
Expand Down Expand Up @@ -2413,15 +2368,6 @@ function reportUpToDateStatus<T extends BuilderProgram>(state: SolutionBuilderSt
relName(state, configFileName),
relName(state, status.upstreamProjectName),
);
case UpToDateStatusType.UpstreamBlocked:
return reportStatus(
state,
status.upstreamProjectBlocked ?
Diagnostics.Project_0_can_t_be_built_because_its_dependency_1_was_not_built :
Diagnostics.Project_0_can_t_be_built_because_its_dependency_1_has_errors,
relName(state, configFileName),
relName(state, status.upstreamProjectName),
);
case UpToDateStatusType.Unbuildable:
return reportStatus(
state,
Expand Down
2 changes: 1 addition & 1 deletion src/testRunner/unittests/tsbuild/sample.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ describe("unittests:: tsbuild:: on 'sample1' project", () => {
describe("downstream-blocked compilations", () => {
verifyTsc({
scenario: "sample1",
subScenario: "does not build downstream projects if upstream projects have errors",
subScenario: "builds downstream projects even if upstream projects have errors",
fs: () => projFs,
commandLineArgs: ["--b", "tests", "--verbose"],
modifyFs: fs => replaceText(fs, "logic/index.ts", "c.multiply(10, 15)", `c.muitply()`),
Expand Down
9 changes: 9 additions & 0 deletions src/testRunner/unittests/tsbuildWatch/programUpdates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,15 @@ createSomeObject().message;`,
caption: "change core",
edit: sys => sys.appendFile("core/index.ts", `\nlet x: string = 10;`),
// Builds core
timeouts: sys => {
sys.runQueuedTimeoutCallbacks();
sys.runQueuedTimeoutCallbacks();
},
},
{
caption: "fix error in logic",
edit: sys => sys.replaceFileText("logic/index.ts", `\nlet y: string = 10;`, ""),
// Builds logic
timeouts: sys => sys.runQueuedTimeoutCallbacks(),
},
],
Expand Down
Loading