Skip to content
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

Remove code related to prepend and fix baselines #57472

Merged
merged 9 commits into from
Feb 28, 2024
30 changes: 4 additions & 26 deletions src/compiler/builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
BuilderProgramHost,
BuilderState,
BuildInfo,
BundleBuildInfo,
CancellationToken,
CommandLineOption,
compareStringsCaseSensitive,
Expand Down Expand Up @@ -76,7 +75,6 @@ import {
sameMap,
SemanticDiagnosticsBuilderProgram,
skipTypeChecking,
some,
SourceFile,
sourceFileMayBeEmitted,
SourceMapEmitResult,
Expand Down Expand Up @@ -171,11 +169,6 @@ export interface ReusableBuilderProgramState extends BuilderState {
* Name of the file whose dts was the latest to change
*/
latestChangedDtsFile: string | undefined;
/**
* @deprecated
* Bundle information either from oldState or current one so it can be used to complete the information in buildInfo when emitting only js or dts files
*/
bundle?: BundleBuildInfo;
}

// dprint-ignore
Expand Down Expand Up @@ -462,12 +455,6 @@ function createBuilderProgramState(newProgram: Program, oldState: Readonly<Reusa
}
}
}
if (outFilePath && !state.changedFilesSet.size) {
// Copy the bundle information from old state so we can patch it later if we are doing partial emit
if (useOldState) state.bundle = oldState!.bundle;
// If this program has prepend references, always emit since we wont know if files on disk are correct unless we check file hash for correctness
if (some(newProgram.getProjectReferences(), ref => !!ref.prepend)) state.programEmitPending = getBuilderFileEmit(compilerOptions);
}
return state;
}

Expand Down Expand Up @@ -1070,7 +1057,7 @@ export function isProgramBundleEmitBuildInfo(info: ProgramBuildInfo): info is Pr
/**
* Gets the program information to be emitted in buildInfo so that we can use it to create new program
*/
function getBuildInfo(state: BuilderProgramState, bundle: BundleBuildInfo | undefined): BuildInfo {
function getBuildInfo(state: BuilderProgramState): BuildInfo {
const currentDirectory = Debug.checkDefined(state.program).getCurrentDirectory();
const buildInfoDirectory = getDirectoryPath(getNormalizedAbsolutePath(getTsBuildInfoEmitOutputFilePath(state.compilerOptions)!, currentDirectory));
// Convert the file name to Path here if we set the fileName instead to optimize multiple d.ts file emits and having to compute Canonical path
Expand Down Expand Up @@ -1102,15 +1089,7 @@ function getBuildInfo(state: BuilderProgramState, bundle: BundleBuildInfo | unde
false : // Pending emit is same as deteremined by compilerOptions
state.programEmitPending, // Actual value
};
// Complete the bundle information if we are doing partial emit (only js or only dts)
const { js, dts, commonSourceDirectory, sourceFiles } = bundle!;
state.bundle = bundle = {
commonSourceDirectory,
sourceFiles,
js: js || (!state.compilerOptions.emitDeclarationOnly ? state.bundle?.js : undefined),
dts: dts || (getEmitDeclarations(state.compilerOptions) ? state.bundle?.dts : undefined),
};
return createBuildInfo(program, bundle);
return createBuildInfo(program);
}

let fileIdsList: (readonly ProgramBuildInfoFileId[])[] | undefined;
Expand Down Expand Up @@ -1215,7 +1194,7 @@ function getBuildInfo(state: BuilderProgramState, bundle: BundleBuildInfo | unde
emitSignatures,
latestChangedDtsFile,
};
return createBuildInfo(program, bundle);
return createBuildInfo(program);

function relativeToBuildInfoEnsuringAbsolutePath(path: string) {
return relativeToBuildInfo(getNormalizedAbsolutePath(path, currentDirectory));
Expand Down Expand Up @@ -1478,7 +1457,7 @@ export function createBuilderProgram(kind: BuilderProgramKind, { newProgram, hos
}

const state = createBuilderProgramState(newProgram, oldState);
newProgram.getBuildInfo = bundle => getBuildInfo(state, bundle);
newProgram.getBuildInfo = () => getBuildInfo(state);

// To ensure that we arent storing any references to old program or new program without state
newProgram = undefined!; // TODO: GH#18217
Expand Down Expand Up @@ -1854,7 +1833,6 @@ export function createBuilderProgramUsingProgramBuildInfo(buildInfo: BuildInfo,
latestChangedDtsFile,
outSignature: program.outSignature,
programEmitPending: program.pendingEmit === undefined ? undefined : toProgramEmitPending(program.pendingEmit, program.options),
bundle: buildInfo.bundle,
};
}
else {
Expand Down
3 changes: 3 additions & 0 deletions src/compiler/commandLineParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -813,6 +813,9 @@ const commandOptionsWithoutBuild: CommandLineOption[] = [
{
name: "verbatimModuleSyntax",
type: "boolean",
affectsEmit: true,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this belong in its own PR? Looks unrelated

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was related to baseline i fixed so added it here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As part of 1012104 and c871a27

affectsSemanticDiagnostics: true,
affectsBuildInfo: true,
category: Diagnostics.Interop_Constraints,
description: Diagnostics.Do_not_transform_or_elide_any_imports_or_exports_not_marked_as_type_only_ensuring_they_are_written_in_the_output_file_s_format_based_on_the_module_setting,
defaultValueDescription: false,
Expand Down
24 changes: 0 additions & 24 deletions src/compiler/diagnosticMessages.json
Original file line number Diff line number Diff line change
Expand Up @@ -5472,14 +5472,6 @@
"category": "Error",
"code": 6307
},
"Cannot prepend project '{0}' because it does not have 'outFile' set": {
"category": "Error",
"code": 6308
},
"Output file '{0}' from project '{1}' does not exist": {
"category": "Error",
"code": 6309
},
"Referenced project '{0}' may not disable emit.": {
"category": "Error",
"code": 6310
Expand Down Expand Up @@ -5560,26 +5552,10 @@
"category": "Message",
"code": 6371
},
"Project '{0}' is out of date because output of its dependency '{1}' has changed": {
"category": "Message",
"code": 6372
},
"Updating output of project '{0}'...": {
"category": "Message",
"code": 6373
},
"A non-dry build would update timestamps for output of project '{0}'": {
"category": "Message",
"code": 6374
},
"A non-dry build would update output of project '{0}'": {
"category": "Message",
"code": 6375
},
"Cannot update output of project '{0}' because there was error reading file '{1}'": {
"category": "Message",
"code": 6376
},
"Cannot write file '{0}' because it will overwrite '.tsbuildinfo' file generated by referenced project '{1}'": {
"category": "Error",
"code": 6377
Expand Down
Loading
Loading