Skip to content

Commit 4de704d

Browse files
typescript-botsheetalkamat
authored andcommitted
Serialize compiler options that are needed from old state when creating new state
1 parent 931b20a commit 4de704d

180 files changed

Lines changed: 1409 additions & 3107 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/compiler/builder.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,7 @@ namespace ts {
711711
export interface ProgramBuildInfo {
712712
fileNames: readonly string[];
713713
fileInfos: readonly BuilderState.FileInfo[];
714-
options: CompilerOptions;
714+
options: CompilerOptions | undefined;
715715
fileIdsList?: readonly (readonly number[])[];
716716
referencedMap?: ProgramBuildInfoReferencedMap;
717717
exportedModulesMap?: ProgramBuildInfoReferencedMap;
@@ -787,7 +787,7 @@ namespace ts {
787787
return {
788788
fileNames,
789789
fileInfos,
790-
options: convertToReusableCompilerOptions(state.compilerOptions, relativeToBuildInfoEnsuringAbsolutePath),
790+
options: convertToProgramBuildInfoCompilerOptions(state.compilerOptions, relativeToBuildInfoEnsuringAbsolutePath),
791791
fileIdsList,
792792
referencedMap,
793793
exportedModulesMap,
@@ -824,19 +824,19 @@ namespace ts {
824824
}
825825
}
826826

827-
function convertToReusableCompilerOptions(options: CompilerOptions, relativeToBuildInfo: (path: string) => string) {
828-
const result: CompilerOptions = {};
827+
function convertToProgramBuildInfoCompilerOptions(options: CompilerOptions, relativeToBuildInfo: (path: string) => string) {
828+
let result: CompilerOptions | undefined;
829829
const { optionsNameMap } = getOptionsNameMap();
830830

831831
for (const name of getOwnKeys(options).sort(compareStringsCaseSensitive)) {
832-
result[name] = convertToReusableCompilerOptionValue(
833-
optionsNameMap.get(name.toLowerCase()),
834-
options[name] as CompilerOptionsValue,
835-
relativeToBuildInfo
836-
);
837-
}
838-
if (result.configFilePath) {
839-
result.configFilePath = relativeToBuildInfo(result.configFilePath);
832+
const optionInfo = optionsNameMap.get(name.toLowerCase());
833+
if (optionInfo?.affectsEmit || optionInfo?.affectsSemanticDiagnostics || name === "skipLibCheck" || name === "skipDefaultLibCheck") {
834+
(result ||= {})[name] = convertToReusableCompilerOptionValue(
835+
optionInfo,
836+
options[name] as CompilerOptionsValue,
837+
relativeToBuildInfo
838+
);
839+
}
840840
}
841841
return result;
842842
}
@@ -1221,7 +1221,7 @@ namespace ts {
12211221
program.fileInfos.forEach((fileInfo, index) => fileInfos.set(toFilePath(index + 1), fileInfo));
12221222
const state: ReusableBuilderProgramState = {
12231223
fileInfos,
1224-
compilerOptions: convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath),
1224+
compilerOptions: program.options ? convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath) : {},
12251225
referencedMap: toMapOfReferencedSet(program.referencedMap),
12261226
exportedModulesMap: toMapOfReferencedSet(program.exportedModulesMap),
12271227
semanticDiagnosticsPerFile: program.semanticDiagnosticsPerFile && arrayToMap(program.semanticDiagnosticsPerFile, value => toFilePath(isNumber(value) ? value : value[0]), value => isNumber(value) ? emptyArray : value[1]),

src/testRunner/unittests/tsbuild/helpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ interface Symbol {
242242
fileNames: readonly string[];
243243
fileNamesList: readonly (readonly string[])[] | undefined;
244244
fileInfos: MapLike<BuilderState.FileInfo>;
245-
options: CompilerOptions;
245+
options: CompilerOptions | undefined;
246246
referencedMap?: MapLike<string[]>;
247247
exportedModulesMap?: MapLike<string[]>;
248248
semanticDiagnosticsPerFile?: readonly ProgramBuildInfoDiagnostic[];

tests/baselines/reference/tsbuild/configFileErrors/incremental-declaration-changes/builds-after-fixing-config-file-errors.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ exports.bar = bar;
3434

3535

3636
//// [/src/tsconfig.tsbuildinfo]
37-
{"program":{"fileNames":["../lib/lib.d.ts","./a.ts","./b.ts"],"fileInfos":[{"version":"3858781397-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }\ninterface ReadonlyArray<T> {}\ndeclare const console: { log(msg: any): void; };","signature":"3858781397-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }\ninterface ReadonlyArray<T> {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},{"version":"4646078106-export function foo() { }","signature":"4646078106-export function foo() { }","affectsGlobalScope":false},{"version":"1045484683-export function bar() { }","signature":"1045484683-export function bar() { }","affectsGlobalScope":false}],"options":{"composite":true,"configFilePath":"./tsconfig.json","declaration":true},"referencedMap":[],"exportedModulesMap":[],"semanticDiagnosticsPerFile":[1,2,3]},"version":"FakeTSVersion"}
37+
{"program":{"fileNames":["../lib/lib.d.ts","./a.ts","./b.ts"],"fileInfos":[{"version":"3858781397-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }\ninterface ReadonlyArray<T> {}\ndeclare const console: { log(msg: any): void; };","signature":"3858781397-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }\ninterface ReadonlyArray<T> {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},{"version":"4646078106-export function foo() { }","signature":"4646078106-export function foo() { }","affectsGlobalScope":false},{"version":"1045484683-export function bar() { }","signature":"1045484683-export function bar() { }","affectsGlobalScope":false}],"options":{"composite":true,"declaration":true},"referencedMap":[],"exportedModulesMap":[],"semanticDiagnosticsPerFile":[1,2,3]},"version":"FakeTSVersion"}
3838

3939
//// [/src/tsconfig.tsbuildinfo.readable.baseline.txt]
4040
{
@@ -63,7 +63,6 @@ exports.bar = bar;
6363
},
6464
"options": {
6565
"composite": true,
66-
"configFilePath": "./tsconfig.json",
6766
"declaration": true
6867
},
6968
"referencedMap": {},
@@ -75,6 +74,6 @@ exports.bar = bar;
7574
]
7675
},
7776
"version": "FakeTSVersion",
78-
"size": 1456
77+
"size": 1421
7978
}
8079

tests/baselines/reference/tsbuild/configFileExtends/initial-build/when-building-project-uses-reference-and-both-extend-config-with-include.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ exports.a = 1;
7272

7373

7474
//// [/src/target-tsc-build/shared/tsconfig.tsbuildinfo]
75-
{"program":{"fileNames":["../../../lib/lib.d.ts","../../shared/index.ts","../../shared/typings-base/globals.d.ts"],"fileInfos":[{"version":"3858781397-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }\ninterface ReadonlyArray<T> {}\ndeclare const console: { log(msg: any): void; };","signature":"3858781397-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }\ninterface ReadonlyArray<T> {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},{"version":"-22125360210-export const a: Unrestricted = 1;","signature":"-22125360210-export const a: Unrestricted = 1;","affectsGlobalScope":false},{"version":"4725476611-type Unrestricted = any;","signature":"4725476611-type Unrestricted = any;","affectsGlobalScope":true}],"options":{"composite":true,"configFilePath":"../../shared/tsconfig.json","listFiles":true,"outDir":"..","rootDir":"../.."},"referencedMap":[],"exportedModulesMap":[],"semanticDiagnosticsPerFile":[1,2,3]},"version":"FakeTSVersion"}
75+
{"program":{"fileNames":["../../../lib/lib.d.ts","../../shared/index.ts","../../shared/typings-base/globals.d.ts"],"fileInfos":[{"version":"3858781397-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }\ninterface ReadonlyArray<T> {}\ndeclare const console: { log(msg: any): void; };","signature":"3858781397-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }\ninterface ReadonlyArray<T> {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},{"version":"-22125360210-export const a: Unrestricted = 1;","signature":"-22125360210-export const a: Unrestricted = 1;","affectsGlobalScope":false},{"version":"4725476611-type Unrestricted = any;","signature":"4725476611-type Unrestricted = any;","affectsGlobalScope":true}],"options":{"composite":true,"outDir":"..","rootDir":"../.."},"referencedMap":[],"exportedModulesMap":[],"semanticDiagnosticsPerFile":[1,2,3]},"version":"FakeTSVersion"}
7676

7777
//// [/src/target-tsc-build/shared/tsconfig.tsbuildinfo.readable.baseline.txt]
7878
{
@@ -101,8 +101,6 @@ exports.a = 1;
101101
},
102102
"options": {
103103
"composite": true,
104-
"configFilePath": "../../shared/tsconfig.json",
105-
"listFiles": true,
106104
"outDir": "..",
107105
"rootDir": "../.."
108106
},
@@ -115,7 +113,7 @@ exports.a = 1;
115113
]
116114
},
117115
"version": "FakeTSVersion",
118-
"size": 1567
116+
"size": 1504
119117
}
120118

121119
//// [/src/target-tsc-build/webpack/index.d.ts]
@@ -130,7 +128,7 @@ exports.b = 1;
130128

131129

132130
//// [/src/target-tsc-build/webpack/tsconfig.tsbuildinfo]
133-
{"program":{"fileNames":["../../../lib/lib.d.ts","../../webpack/index.ts","../../shared/typings-base/globals.d.ts"],"fileInfos":[{"version":"3858781397-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }\ninterface ReadonlyArray<T> {}\ndeclare const console: { log(msg: any): void; };","signature":"3858781397-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }\ninterface ReadonlyArray<T> {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},{"version":"-14405273073-export const b: Unrestricted = 1;","signature":"-14405273073-export const b: Unrestricted = 1;","affectsGlobalScope":false},{"version":"4725476611-type Unrestricted = any;","signature":"4725476611-type Unrestricted = any;","affectsGlobalScope":true}],"options":{"composite":true,"configFilePath":"../../webpack/tsconfig.json","listFiles":true,"outDir":"..","rootDir":"../.."},"referencedMap":[],"exportedModulesMap":[],"semanticDiagnosticsPerFile":[1,3,2]},"version":"FakeTSVersion"}
131+
{"program":{"fileNames":["../../../lib/lib.d.ts","../../webpack/index.ts","../../shared/typings-base/globals.d.ts"],"fileInfos":[{"version":"3858781397-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }\ninterface ReadonlyArray<T> {}\ndeclare const console: { log(msg: any): void; };","signature":"3858781397-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }\ninterface ReadonlyArray<T> {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},{"version":"-14405273073-export const b: Unrestricted = 1;","signature":"-14405273073-export const b: Unrestricted = 1;","affectsGlobalScope":false},{"version":"4725476611-type Unrestricted = any;","signature":"4725476611-type Unrestricted = any;","affectsGlobalScope":true}],"options":{"composite":true,"outDir":"..","rootDir":"../.."},"referencedMap":[],"exportedModulesMap":[],"semanticDiagnosticsPerFile":[1,3,2]},"version":"FakeTSVersion"}
134132

135133
//// [/src/target-tsc-build/webpack/tsconfig.tsbuildinfo.readable.baseline.txt]
136134
{
@@ -159,8 +157,6 @@ exports.b = 1;
159157
},
160158
"options": {
161159
"composite": true,
162-
"configFilePath": "../../webpack/tsconfig.json",
163-
"listFiles": true,
164160
"outDir": "..",
165161
"rootDir": "../.."
166162
},
@@ -173,6 +169,6 @@ exports.b = 1;
173169
]
174170
},
175171
"version": "FakeTSVersion",
176-
"size": 1569
172+
"size": 1505
177173
}
178174

0 commit comments

Comments
 (0)