mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-09 20:51:43 -06:00
Baseline tsbuild info section files from written files
This commit is contained in:
parent
bfc4f7a12f
commit
e43d504422
@ -308,6 +308,7 @@ namespace ts {
|
||||
/*@internal*/ getUpToDateStatusOfProject(project: string): UpToDateStatus;
|
||||
/*@internal*/ invalidateProject(configFilePath: ResolvedConfigFilePath, reloadLevel?: ConfigFileProgramReloadLevel): void;
|
||||
/*@internal*/ buildNextInvalidatedProject(): void;
|
||||
/*@internal*/ getAllParsedConfigs(): readonly ParsedCommandLine[];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2047,6 +2048,10 @@ namespace ts {
|
||||
},
|
||||
invalidateProject: (configFilePath, reloadLevel) => invalidateProject(state, configFilePath, reloadLevel || ConfigFileProgramReloadLevel.None),
|
||||
buildNextInvalidatedProject: () => buildNextInvalidatedProject(state),
|
||||
getAllParsedConfigs: () => arrayFrom(mapDefinedIterator(
|
||||
state.configFileCache.values(),
|
||||
config => isParsedCommandLine(config) ? config : undefined
|
||||
)),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -2,26 +2,8 @@ namespace ts {
|
||||
describe("unittests:: tsbuild:: outFile:: on amd modules with --out", () => {
|
||||
let outFileFs: vfs.FileSystem;
|
||||
const { time, tick } = getTime();
|
||||
const enum ext { js, jsmap, dts, dtsmap, buildinfo }
|
||||
const enum project { lib, app }
|
||||
type OutputFile = [string, string, string, string, string];
|
||||
function relName(path: string) { return path.slice(1); }
|
||||
const outputFiles: [OutputFile, OutputFile] = [
|
||||
[
|
||||
"/src/lib/module.js",
|
||||
"/src/lib/module.js.map",
|
||||
"/src/lib/module.d.ts",
|
||||
"/src/lib/module.d.ts.map",
|
||||
"/src/lib/module.tsbuildinfo"
|
||||
],
|
||||
[
|
||||
"/src/app/module.js",
|
||||
"/src/app/module.js.map",
|
||||
"/src/app/module.d.ts",
|
||||
"/src/app/module.d.ts.map",
|
||||
"/src/app/module.tsbuildinfo"
|
||||
]
|
||||
];
|
||||
type Sources = [string, ReadonlyArray<string>];
|
||||
const enum source { config, ts }
|
||||
const sources: [Sources, Sources] = [
|
||||
@ -68,10 +50,6 @@ namespace ts {
|
||||
proj: "amdModulesWithOut",
|
||||
rootNames: ["/src/app"],
|
||||
baselineSourceMap: true,
|
||||
expectedBuildInfoFilesForSectionBaselines: [
|
||||
[outputFiles[project.lib][ext.buildinfo], outputFiles[project.lib][ext.js], outputFiles[project.lib][ext.dts]],
|
||||
[outputFiles[project.app][ext.buildinfo], outputFiles[project.app][ext.js], outputFiles[project.app][ext.dts]]
|
||||
],
|
||||
initialBuild: {
|
||||
modifyFs
|
||||
},
|
||||
@ -197,13 +175,6 @@ ${internal} export enum internalEnum { a, b, c }`);
|
||||
replaceText(fs, sources[project.app][source.ts][0], "file1", "lib/file1");
|
||||
}
|
||||
|
||||
const libOutputFile: OutputFile = [
|
||||
"/src/lib/module.js",
|
||||
"/src/lib/module.js.map",
|
||||
"/src/lib/module.d.ts",
|
||||
"/src/lib/module.d.ts.map",
|
||||
"/src/lib/module.tsbuildinfo"
|
||||
];
|
||||
verifyTsbuildOutput({
|
||||
scenario: "when the module resolution finds original source file",
|
||||
projFs: () => outFileFs,
|
||||
@ -212,10 +183,6 @@ ${internal} export enum internalEnum { a, b, c }`);
|
||||
proj: "amdModulesWithOut",
|
||||
rootNames: ["/src/app"],
|
||||
baselineSourceMap: true,
|
||||
expectedBuildInfoFilesForSectionBaselines: [
|
||||
[libOutputFile[ext.buildinfo], libOutputFile[ext.js], libOutputFile[ext.dts]],
|
||||
[outputFiles[project.app][ext.buildinfo], outputFiles[project.app][ext.js], outputFiles[project.app][ext.dts]]
|
||||
],
|
||||
initialBuild: {
|
||||
modifyFs,
|
||||
expectedDiagnostics: [
|
||||
|
||||
@ -235,12 +235,12 @@ interface Symbol {
|
||||
fs: vfs.FileSystem;
|
||||
tick: () => void;
|
||||
rootNames: ReadonlyArray<string>;
|
||||
baselineSourceMap?: true;
|
||||
expectedBuildInfoFilesForSectionBaselines?: ReadonlyArray<BuildInfoSectionBaselineFiles>;
|
||||
modifyFs: (fs: vfs.FileSystem) => void;
|
||||
baselineSourceMap?: true;
|
||||
baselineBuildInfo?: true;
|
||||
}
|
||||
|
||||
function build({ fs, tick, rootNames, baselineSourceMap, expectedBuildInfoFilesForSectionBaselines, modifyFs }: BuildInput) {
|
||||
function build({ fs, tick, rootNames, modifyFs, baselineSourceMap, baselineBuildInfo }: BuildInput) {
|
||||
const actualReadFileMap = createMap<number>();
|
||||
modifyFs(fs);
|
||||
tick();
|
||||
@ -265,7 +265,21 @@ interface Symbol {
|
||||
};
|
||||
builder.build();
|
||||
if (baselineSourceMap) generateSourceMapBaselineFiles(fs, mapDefinedIterator(writtenFiles.keys(), f => f.endsWith(".map") ? f : undefined));
|
||||
generateBuildInfoSectionBaselineFiles(fs, expectedBuildInfoFilesForSectionBaselines || emptyArray);
|
||||
if (baselineBuildInfo) {
|
||||
let expectedBuildInfoFiles: BuildInfoSectionBaselineFiles[] | undefined;
|
||||
for (const { options } of builder.getAllParsedConfigs()) {
|
||||
const out = options.outFile || options.out;
|
||||
if (out) {
|
||||
const { jsFilePath, declarationFilePath, buildInfoPath } = getOutputPathsForBundle(options, /*forceDts*/ false);
|
||||
if (buildInfoPath && writtenFiles.has(buildInfoPath)) {
|
||||
(expectedBuildInfoFiles || (expectedBuildInfoFiles = [])).push(
|
||||
[buildInfoPath, jsFilePath, declarationFilePath]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (expectedBuildInfoFiles) generateBuildInfoSectionBaselineFiles(fs, expectedBuildInfoFiles);
|
||||
}
|
||||
fs.makeReadonly();
|
||||
return { fs, actualReadFileMap, host, builder, writtenFiles };
|
||||
}
|
||||
@ -311,7 +325,6 @@ Mismatch Actual(path, actual, expected): ${JSON.stringify(arrayFrom(mapDefinedIt
|
||||
tick: () => void;
|
||||
proj: string;
|
||||
rootNames: ReadonlyArray<string>;
|
||||
expectedBuildInfoFilesForSectionBaselines?: ReadonlyArray<BuildInfoSectionBaselineFiles>;
|
||||
initialBuild: BuildState;
|
||||
incrementalDtsChangedBuild?: BuildState;
|
||||
incrementalDtsUnchangedBuild?: BuildState;
|
||||
@ -322,8 +335,8 @@ Mismatch Actual(path, actual, expected): ${JSON.stringify(arrayFrom(mapDefinedIt
|
||||
}
|
||||
|
||||
export function verifyTsbuildOutput({
|
||||
scenario, projFs, time, tick, proj, rootNames, baselineOnly, verifyDiagnostics,
|
||||
baselineSourceMap, expectedBuildInfoFilesForSectionBaselines,
|
||||
scenario, projFs, time, tick, proj, rootNames,
|
||||
baselineOnly, verifyDiagnostics, baselineSourceMap,
|
||||
initialBuild, incrementalDtsChangedBuild, incrementalDtsUnchangedBuild, incrementalHeaderChangedBuild
|
||||
}: VerifyTsBuildInput) {
|
||||
describe(`tsc --b ${proj}:: ${scenario}`, () => {
|
||||
@ -337,9 +350,9 @@ Mismatch Actual(path, actual, expected): ${JSON.stringify(arrayFrom(mapDefinedIt
|
||||
fs: projFs().shadow(),
|
||||
tick,
|
||||
rootNames,
|
||||
baselineSourceMap,
|
||||
expectedBuildInfoFilesForSectionBaselines,
|
||||
modifyFs: initialBuild.modifyFs,
|
||||
baselineSourceMap,
|
||||
baselineBuildInfo: true,
|
||||
});
|
||||
({ fs, actualReadFileMap, host, writtenFiles: initialWrittenFiles } = result);
|
||||
firstBuildTime = time();
|
||||
@ -383,9 +396,9 @@ Mismatch Actual(path, actual, expected): ${JSON.stringify(arrayFrom(mapDefinedIt
|
||||
fs: newFs,
|
||||
tick,
|
||||
rootNames,
|
||||
baselineSourceMap,
|
||||
expectedBuildInfoFilesForSectionBaselines,
|
||||
modifyFs: incrementalModifyFs,
|
||||
baselineSourceMap,
|
||||
baselineBuildInfo: true,
|
||||
}));
|
||||
afterBuildTime = newFs.statSync(lastProjectOutput).mtimeMs;
|
||||
});
|
||||
|
||||
@ -55,11 +55,6 @@ namespace ts {
|
||||
]
|
||||
]
|
||||
];
|
||||
const expectedTsbuildInfoFileNames: ReadonlyArray<BuildInfoSectionBaselineFiles> = [
|
||||
[outputFiles[project.first][ext.buildinfo], outputFiles[project.first][ext.js], outputFiles[project.first][ext.dts]],
|
||||
[outputFiles[project.second][ext.buildinfo], outputFiles[project.second][ext.js], outputFiles[project.second][ext.dts]],
|
||||
[outputFiles[project.third][ext.buildinfo], outputFiles[project.third][ext.js], outputFiles[project.third][ext.dts]]
|
||||
];
|
||||
const relSources = sources.map(([config, sources]) => [relName(config), sources.map(relName)]) as any as [Sources, Sources, Sources];
|
||||
const { time, tick } = getTime();
|
||||
let expectedOutputFiles = [
|
||||
@ -244,7 +239,6 @@ namespace ts {
|
||||
modifyFs: (fs: vfs.FileSystem) => void;
|
||||
modifyAgainFs?: (fs: vfs.FileSystem) => void;
|
||||
additionalSourceFiles?: ReadonlyArray<string>;
|
||||
expectedBuildInfoFilesForSectionBaselines?: ReadonlyArray<BuildInfoSectionBaselineFiles>;
|
||||
dependOrdered?: true;
|
||||
ignoreDtsChanged?: true;
|
||||
ignoreDtsUnchanged?: true;
|
||||
@ -256,7 +250,6 @@ namespace ts {
|
||||
modifyFs,
|
||||
modifyAgainFs,
|
||||
additionalSourceFiles,
|
||||
expectedBuildInfoFilesForSectionBaselines,
|
||||
dependOrdered,
|
||||
ignoreDtsChanged,
|
||||
ignoreDtsUnchanged,
|
||||
@ -279,7 +272,6 @@ namespace ts {
|
||||
proj: "outfile-concat",
|
||||
rootNames: ["/src/third"],
|
||||
baselineSourceMap: true,
|
||||
expectedBuildInfoFilesForSectionBaselines: expectedBuildInfoFilesForSectionBaselines || expectedTsbuildInfoFileNames,
|
||||
initialBuild: {
|
||||
modifyFs,
|
||||
expectedDiagnostics: initialExpectedDiagnostics,
|
||||
@ -334,11 +326,6 @@ namespace ts {
|
||||
scenario: "when final project specifies tsBuildInfoFile",
|
||||
modifyFs: fs => replaceText(fs, sources[project.third][source.config], `"composite": true,`, `"composite": true,
|
||||
"tsBuildInfoFile": "./thirdjs/output/third.tsbuildinfo",`),
|
||||
expectedBuildInfoFilesForSectionBaselines: [
|
||||
expectedTsbuildInfoFileNames[0],
|
||||
expectedTsbuildInfoFileNames[1],
|
||||
["/src/third/thirdjs/output/third.tsbuildinfo", expectedTsbuildInfoFileNames[2][1], expectedTsbuildInfoFileNames[2][2]]
|
||||
],
|
||||
ignoreDtsChanged: true,
|
||||
ignoreDtsUnchanged: true,
|
||||
baselineOnly: true
|
||||
|
||||
@ -803,3 +803,37 @@ sourceFile:lib/global.ts
|
||||
"version": "FakeTSVersion"
|
||||
}
|
||||
|
||||
//// [/src/module.tsbuildinfo.baseline.txt]
|
||||
======================================================================
|
||||
File:: /src/module.js
|
||||
----------------------------------------------------------------------
|
||||
text: (0-417)
|
||||
var myGlob = 20;
|
||||
define("lib/file1", ["require", "exports"], function (require, exports) {
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.x = 10;
|
||||
});
|
||||
define("lib/file2", ["require", "exports"], function (require, exports) {
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.y = 20;
|
||||
});
|
||||
var globalConst = 10;
|
||||
|
||||
======================================================================
|
||||
======================================================================
|
||||
File:: /src/module.d.ts
|
||||
----------------------------------------------------------------------
|
||||
text: (0-179)
|
||||
declare const myGlob = 20;
|
||||
declare module "lib/file1" {
|
||||
export const x = 10;
|
||||
}
|
||||
declare module "lib/file2" {
|
||||
export const y = 20;
|
||||
}
|
||||
declare const globalConst = 10;
|
||||
|
||||
======================================================================
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user