From 23b5b14565f0fe6144314a2106cc260feb2fd513 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Thu, 7 Feb 2019 12:01:12 -0800 Subject: [PATCH] Fix incremental build changes declaration dir --- src/compiler/builder.ts | 13 ++ src/testRunner/unittests/tsbuild/sample.ts | 25 ++- ...en-logic-config-changes-declaration-dir.js | 158 ++++++++++++++++++ 3 files changed, 195 insertions(+), 1 deletion(-) diff --git a/src/compiler/builder.ts b/src/compiler/builder.ts index 8a80dbec72f..b61007730fa 100644 --- a/src/compiler/builder.ts +++ b/src/compiler/builder.ts @@ -209,6 +209,19 @@ namespace ts { } }); + if (oldCompilerOptions && + (oldCompilerOptions.outDir !== compilerOptions.outDir || + oldCompilerOptions.declarationDir !== compilerOptions.declarationDir || + (oldCompilerOptions.outFile || oldCompilerOptions.out) !== (compilerOptions.outFile || compilerOptions.out))) { + // Add all files to affectedFilesPendingEmit since emit changed + state.affectedFilesPendingEmit = concatenate(state.affectedFilesPendingEmit, newProgram.getSourceFiles().map(f => f.path)); + if (state.affectedFilesPendingEmitIndex === undefined) { + state.affectedFilesPendingEmitIndex = 0; + } + Debug.assert(state.seenAffectedFiles === undefined); + state.seenAffectedFiles = createMap(); + } + return state; } diff --git a/src/testRunner/unittests/tsbuild/sample.ts b/src/testRunner/unittests/tsbuild/sample.ts index 4b9c416963a..9db347745ec 100644 --- a/src/testRunner/unittests/tsbuild/sample.ts +++ b/src/testRunner/unittests/tsbuild/sample.ts @@ -564,7 +564,30 @@ class someClass { }`), [Diagnostics.Building_project_0, "/src/logic/tsconfig.json"], [Diagnostics.Project_0_is_out_of_date_because_oldest_output_1_is_older_than_newest_input_2, "src/tests/tsconfig.json", "src/tests/index.js", "src/logic"], [Diagnostics.Building_project_0, "/src/tests/tsconfig.json"], - ] + ], + expectedReadFiles: getReadFilesMap( + [ + // Configs + "/src/core/tsconfig.json", + "/src/logic/tsconfig.json", + "/src/tests/tsconfig.json", + + // Source files + "/src/logic/index.ts", + "/src/tests/index.ts", + + // Modules of generated files + "/src/core/anotherModule.d.ts", + "/src/core/index.d.ts", + "/src/logic/decls/index.d.ts", + + // build info + "/src/logic/.tsbuildinfo", + "/src/tests/.tsbuildinfo", + + "/src/tests/index.d.ts", // to check if d.ts has changed + ] + ) } }); }); diff --git a/tests/baselines/reference/tsbuild/sample1/incremental-declaration-changes/buildInfo/when-logic-config-changes-declaration-dir.js b/tests/baselines/reference/tsbuild/sample1/incremental-declaration-changes/buildInfo/when-logic-config-changes-declaration-dir.js index 4733c81e58b..897e05b2993 100644 --- a/tests/baselines/reference/tsbuild/sample1/incremental-declaration-changes/buildInfo/when-logic-config-changes-declaration-dir.js +++ b/tests/baselines/reference/tsbuild/sample1/incremental-declaration-changes/buildInfo/when-logic-config-changes-declaration-dir.js @@ -1,3 +1,77 @@ +//// [/src/logic/.tsbuildinfo] +{ + "js": [], + "dts": [], + "commonSourceDirectory": "/src/logic/", + "sources": {}, + "program": { + "fileInfos": { + "/lib/lib.d.ts": { + "version": "38840781448", + "signature": "38840781448" + }, + "/lib/lib.es5.d.ts": { + "version": "-157947125741", + "signature": "-157947125741" + }, + "/lib/lib.dom.d.ts": { + "version": "-1086375748659", + "signature": "-1086375748659" + }, + "/lib/lib.webworker.importscripts.d.ts": { + "version": "16827914512", + "signature": "16827914512" + }, + "/lib/lib.scripthost.d.ts": { + "version": "-7856822451", + "signature": "-7856822451" + }, + "/src/core/index.ts": { + "version": "-13851440507", + "signature": "-13851440507" + }, + "/src/core/anothermodule.ts": { + "version": "7652028357", + "signature": "7652028357" + }, + "/src/logic/index.ts": { + "version": "-5786964698", + "signature": "-6548680073" + } + }, + "options": { + "composite": true, + "declaration": true, + "declarationDir": "/src/logic/decls", + "sourceMap": true, + "forceConsistentCasingInFileNames": true, + "skipDefaultLibCheck": true, + "configFilePath": "/src/logic/tsconfig.json" + }, + "referencedMap": { + "/src/logic/index.ts": [ + "/src/core/index.d.ts", + "/src/core/anothermodule.d.ts" + ] + }, + "exportedModulesMap": { + "/src/logic/index.ts": [ + "/src/core/anothermodule.d.ts" + ] + }, + "semanticDiagnosticsPerFile": [ + "/lib/lib.d.ts", + "/lib/lib.es5.d.ts", + "/lib/lib.dom.d.ts", + "/lib/lib.webworker.importscripts.d.ts", + "/lib/lib.scripthost.d.ts", + "/src/core/index.ts", + "/src/core/anothermodule.ts", + "/src/logic/index.ts" + ] + } +} + //// [/src/logic/decls/index.d.ts] export declare function getSecondsInDay(): number; import * as mod from '../core/anotherModule'; @@ -20,3 +94,87 @@ export declare const m: typeof mod; } +//// [/src/tests/.tsbuildinfo] +{ + "js": [], + "dts": [], + "commonSourceDirectory": "/src/tests/", + "sources": {}, + "program": { + "fileInfos": { + "/lib/lib.d.ts": { + "version": "38840781448", + "signature": "38840781448" + }, + "/lib/lib.es5.d.ts": { + "version": "-157947125741", + "signature": "-157947125741" + }, + "/lib/lib.dom.d.ts": { + "version": "-1086375748659", + "signature": "-1086375748659" + }, + "/lib/lib.webworker.importscripts.d.ts": { + "version": "16827914512", + "signature": "16827914512" + }, + "/lib/lib.scripthost.d.ts": { + "version": "-7856822451", + "signature": "-7856822451" + }, + "/src/core/index.ts": { + "version": "-13851440507", + "signature": "-13851440507" + }, + "/src/core/anothermodule.ts": { + "version": "7652028357", + "signature": "7652028357" + }, + "/src/logic/index.ts": { + "version": "-6548680073", + "signature": "-6548680073" + }, + "/src/tests/index.ts": { + "version": "12336236525", + "signature": "-9209611" + } + }, + "options": { + "composite": true, + "declaration": true, + "forceConsistentCasingInFileNames": true, + "skipDefaultLibCheck": true, + "configFilePath": "/src/tests/tsconfig.json" + }, + "referencedMap": { + "/src/logic/index.ts": [ + "/src/core/anothermodule.d.ts" + ], + "/src/tests/index.ts": [ + "/src/core/index.d.ts", + "/src/logic/decls/index.d.ts", + "/src/core/anothermodule.d.ts" + ] + }, + "exportedModulesMap": { + "/src/logic/index.ts": [ + "/src/core/anothermodule.d.ts" + ], + "/src/tests/index.ts": [ + "/src/core/anothermodule.d.ts" + ] + }, + "semanticDiagnosticsPerFile": [ + "/lib/lib.d.ts", + "/lib/lib.es5.d.ts", + "/lib/lib.dom.d.ts", + "/lib/lib.webworker.importscripts.d.ts", + "/lib/lib.scripthost.d.ts", + "/src/core/index.ts", + "/src/core/anothermodule.ts", + "/src/logic/index.ts", + "/src/tests/index.ts" + ] + } +} +