mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Make the bundle info into buildInfo
This commit is contained in:
+31
-31
@@ -46,8 +46,8 @@ namespace ts {
|
||||
const sourceMapFilePath = jsFilePath && getSourceMapFilePath(jsFilePath, options);
|
||||
const declarationFilePath = (forceDtsPaths || getEmitDeclarations(options)) ? removeFileExtension(outPath) + Extension.Dts : undefined;
|
||||
const declarationMapPath = declarationFilePath && getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : undefined;
|
||||
const bundleInfoPath = options.composite && jsFilePath ? combinePaths(getDirectoryPath(jsFilePath), infoFile) : undefined;
|
||||
return { jsFilePath, sourceMapFilePath, declarationFilePath, declarationMapPath, bundleInfoPath };
|
||||
const buildInfoPath = options.composite && jsFilePath ? combinePaths(getDirectoryPath(jsFilePath), infoFile) : undefined;
|
||||
return { jsFilePath, sourceMapFilePath, declarationFilePath, declarationMapPath, buildInfoPath };
|
||||
}
|
||||
|
||||
/*@internal*/
|
||||
@@ -67,7 +67,7 @@ namespace ts {
|
||||
const isJs = isSourceFileJS(sourceFile);
|
||||
const declarationFilePath = ((forceDtsPaths || getEmitDeclarations(options)) && !isJs) ? getDeclarationEmitOutputFilePath(sourceFile.fileName, host) : undefined;
|
||||
const declarationMapPath = declarationFilePath && getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : undefined;
|
||||
return { jsFilePath, sourceMapFilePath, declarationFilePath, declarationMapPath, bundleInfoPath: undefined };
|
||||
return { jsFilePath, sourceMapFilePath, declarationFilePath, declarationMapPath, buildInfoPath: undefined };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ namespace ts {
|
||||
const newLine = getNewLineCharacter(compilerOptions, () => host.getNewLine());
|
||||
const writer = createTextWriter(newLine);
|
||||
const { enter, exit } = performance.createTimer("printTime", "beforePrint", "afterPrint");
|
||||
let bundleInfo: BundleInfo | undefined;
|
||||
let buildInfo: BuildInfo | undefined;
|
||||
let emitSkipped = false;
|
||||
let exportedModulesFromDeclarationEmit: ExportedModulesFromDeclarationEmit | undefined;
|
||||
|
||||
@@ -126,13 +126,13 @@ namespace ts {
|
||||
exportedModulesFromDeclarationEmit
|
||||
};
|
||||
|
||||
function emitSourceFileOrBundle({ jsFilePath, sourceMapFilePath, declarationFilePath, declarationMapPath, bundleInfoPath }: EmitFileNames, sourceFileOrBundle: SourceFile | Bundle) {
|
||||
if (bundleInfoPath && !emitOnlyDtsFiles) bundleInfo = { js: [], dts: [] };
|
||||
emitJsFileOrBundle(sourceFileOrBundle, jsFilePath, sourceMapFilePath, bundleInfo && bundleInfo.js);
|
||||
emitDeclarationFileOrBundle(sourceFileOrBundle, declarationFilePath, declarationMapPath, bundleInfo && bundleInfo.dts);
|
||||
function emitSourceFileOrBundle({ jsFilePath, sourceMapFilePath, declarationFilePath, declarationMapPath, buildInfoPath }: EmitFileNames, sourceFileOrBundle: SourceFile | Bundle) {
|
||||
if (buildInfoPath && !emitOnlyDtsFiles) buildInfo = { js: [], dts: [] };
|
||||
emitJsFileOrBundle(sourceFileOrBundle, jsFilePath, sourceMapFilePath, buildInfo && buildInfo.js);
|
||||
emitDeclarationFileOrBundle(sourceFileOrBundle, declarationFilePath, declarationMapPath, buildInfo && buildInfo.dts);
|
||||
// Write bundled offset information if applicable
|
||||
if (!emitOnlyDtsFiles && !emitSkipped && bundleInfoPath) {
|
||||
writeFile(host, emitterDiagnostics, bundleInfoPath, JSON.stringify(bundleInfo, undefined, 2), /*writeByteOrderMark*/ false);
|
||||
if (!emitOnlyDtsFiles && !emitSkipped && buildInfoPath) {
|
||||
writeFile(host, emitterDiagnostics, buildInfoPath, JSON.stringify(buildInfo, undefined, 2), /*writeByteOrderMark*/ false);
|
||||
}
|
||||
|
||||
if (!emitSkipped && emittedFilesList) {
|
||||
@@ -143,8 +143,8 @@ namespace ts {
|
||||
if (sourceMapFilePath) {
|
||||
emittedFilesList.push(sourceMapFilePath);
|
||||
}
|
||||
if (bundleInfoPath) {
|
||||
emittedFilesList.push(bundleInfoPath);
|
||||
if (buildInfoPath) {
|
||||
emittedFilesList.push(buildInfoPath);
|
||||
}
|
||||
}
|
||||
if (declarationFilePath) {
|
||||
@@ -156,7 +156,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function emitJsFileOrBundle(sourceFileOrBundle: SourceFile | Bundle, jsFilePath: string | undefined, sourceMapFilePath: string | undefined, fileBundleInfo: FileBundleInfo | undefined) {
|
||||
function emitJsFileOrBundle(sourceFileOrBundle: SourceFile | Bundle, jsFilePath: string | undefined, sourceMapFilePath: string | undefined, bundleFileInfo: BundleFileInfo | undefined) {
|
||||
if (emitOnlyDtsFiles || !jsFilePath) {
|
||||
return;
|
||||
}
|
||||
@@ -192,13 +192,13 @@ namespace ts {
|
||||
});
|
||||
|
||||
Debug.assert(transform.transformed.length === 1, "Should only see one output from the transform");
|
||||
printSourceFileOrBundle(jsFilePath, sourceMapFilePath, transform.transformed[0], fileBundleInfo, printer, compilerOptions);
|
||||
printSourceFileOrBundle(jsFilePath, sourceMapFilePath, transform.transformed[0], bundleFileInfo, printer, compilerOptions);
|
||||
|
||||
// Clean up emit nodes on parse tree
|
||||
transform.dispose();
|
||||
}
|
||||
|
||||
function emitDeclarationFileOrBundle(sourceFileOrBundle: SourceFile | Bundle, declarationFilePath: string | undefined, declarationMapPath: string | undefined, fileBundleInfo: FileBundleInfo | undefined) {
|
||||
function emitDeclarationFileOrBundle(sourceFileOrBundle: SourceFile | Bundle, declarationFilePath: string | undefined, declarationMapPath: string | undefined, bundleFileInfo: BundleFileInfo | undefined) {
|
||||
if (!(declarationFilePath && !isInJSFile(sourceFileOrBundle))) {
|
||||
return;
|
||||
}
|
||||
@@ -242,7 +242,7 @@ namespace ts {
|
||||
emitSkipped = emitSkipped || declBlocked;
|
||||
if (!declBlocked || emitOnlyDtsFiles) {
|
||||
Debug.assert(declarationTransform.transformed.length === 1, "Should only see one output from the decl transform");
|
||||
printSourceFileOrBundle(declarationFilePath, declarationMapPath, declarationTransform.transformed[0], fileBundleInfo, declarationPrinter, {
|
||||
printSourceFileOrBundle(declarationFilePath, declarationMapPath, declarationTransform.transformed[0], bundleFileInfo, declarationPrinter, {
|
||||
sourceMap: compilerOptions.declarationMap,
|
||||
sourceRoot: compilerOptions.sourceRoot,
|
||||
mapRoot: compilerOptions.mapRoot,
|
||||
@@ -271,7 +271,7 @@ namespace ts {
|
||||
forEachChild(node, collectLinkedAliases);
|
||||
}
|
||||
|
||||
function printSourceFileOrBundle(jsFilePath: string, sourceMapFilePath: string | undefined, sourceFileOrBundle: SourceFile | Bundle, fileBundleInfo: FileBundleInfo | undefined, printer: Printer, mapOptions: SourceMapOptions) {
|
||||
function printSourceFileOrBundle(jsFilePath: string, sourceMapFilePath: string | undefined, sourceFileOrBundle: SourceFile | Bundle, bundleFileInfo: BundleFileInfo | undefined, printer: Printer, mapOptions: SourceMapOptions) {
|
||||
const bundle = sourceFileOrBundle.kind === SyntaxKind.Bundle ? sourceFileOrBundle : undefined;
|
||||
const sourceFile = sourceFileOrBundle.kind === SyntaxKind.SourceFile ? sourceFileOrBundle : undefined;
|
||||
const sourceFiles = bundle ? bundle.sourceFiles : [sourceFile!];
|
||||
@@ -287,7 +287,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
if (bundle) {
|
||||
printer.writeBundle(bundle, fileBundleInfo, writer, sourceMapGenerator);
|
||||
printer.writeBundle(bundle, bundleFileInfo, writer, sourceMapGenerator);
|
||||
}
|
||||
else {
|
||||
printer.writeFile(sourceFile!, writer, sourceMapGenerator);
|
||||
@@ -440,7 +440,7 @@ namespace ts {
|
||||
let ownWriter: EmitTextWriter; // Reusable `EmitTextWriter` for basic printing.
|
||||
let write = writeBase;
|
||||
let isOwnFileEmit: boolean;
|
||||
let fileBundleInfo: FileBundleInfo | undefined;
|
||||
let bundleFileInfo: BundleFileInfo | undefined;
|
||||
|
||||
// Source Maps
|
||||
let sourceMapsDisabled = true;
|
||||
@@ -542,9 +542,9 @@ namespace ts {
|
||||
return writer.getTextPosWithWriteLine ? writer.getTextPosWithWriteLine() : writer.getTextPos();
|
||||
}
|
||||
|
||||
function writeBundle(bundle: Bundle, bundleInfo: FileBundleInfo | undefined, output: EmitTextWriter, sourceMapGenerator: SourceMapGenerator | undefined) {
|
||||
function writeBundle(bundle: Bundle, bundleInfo: BundleFileInfo | undefined, output: EmitTextWriter, sourceMapGenerator: SourceMapGenerator | undefined) {
|
||||
isOwnFileEmit = false;
|
||||
fileBundleInfo = bundleInfo;
|
||||
bundleFileInfo = bundleInfo;
|
||||
const previousWriter = writer;
|
||||
setWriter(output, sourceMapGenerator);
|
||||
emitShebangIfNeeded(bundle);
|
||||
@@ -561,7 +561,7 @@ namespace ts {
|
||||
for (const sourceFile of bundle.sourceFiles) {
|
||||
print(EmitHint.SourceFile, sourceFile, sourceFile);
|
||||
}
|
||||
if (fileBundleInfo) fileBundleInfo.push({ pos, end: writer.getTextPos(), kind: BundleFileSectionKind.Text });
|
||||
if (bundleFileInfo) bundleFileInfo.push({ pos, end: writer.getTextPos(), kind: BundleFileSectionKind.Text });
|
||||
|
||||
reset();
|
||||
writer = previousWriter;
|
||||
@@ -577,7 +577,7 @@ namespace ts {
|
||||
|
||||
function writeFile(sourceFile: SourceFile, output: EmitTextWriter, sourceMapGenerator: SourceMapGenerator | undefined) {
|
||||
isOwnFileEmit = true;
|
||||
fileBundleInfo = undefined;
|
||||
bundleFileInfo = undefined;
|
||||
const previousWriter = writer;
|
||||
setWriter(output, sourceMapGenerator);
|
||||
emitShebangIfNeeded(sourceFile);
|
||||
@@ -635,7 +635,7 @@ namespace ts {
|
||||
currentSourceFile = undefined!;
|
||||
currentLineMap = undefined!;
|
||||
detachedCommentsInfo = undefined;
|
||||
fileBundleInfo = undefined;
|
||||
bundleFileInfo = undefined;
|
||||
setWriter(/*output*/ undefined, /*_sourceMapGenerator*/ undefined);
|
||||
}
|
||||
|
||||
@@ -1171,7 +1171,7 @@ namespace ts {
|
||||
else {
|
||||
writeLines(helper.text(makeFileLevelOptimisticUniqueName));
|
||||
}
|
||||
if (fileBundleInfo) fileBundleInfo.push({ pos, end: writer.getTextPos(), kind: BundleFileSectionKind.EmitHelpers, name: helper.name });
|
||||
if (bundleFileInfo) bundleFileInfo.push({ pos, end: writer.getTextPos(), kind: BundleFileSectionKind.EmitHelpers, name: helper.name });
|
||||
helpersEmitted = true;
|
||||
}
|
||||
}
|
||||
@@ -2938,7 +2938,7 @@ namespace ts {
|
||||
if (hasNoDefaultLib) {
|
||||
const pos = writer.getTextPos();
|
||||
writeComment(`/// <reference no-default-lib="true"/>`);
|
||||
if (fileBundleInfo) fileBundleInfo.push({ pos, end: writer.getTextPos(), kind: BundleFileSectionKind.NoDefaultLib });
|
||||
if (bundleFileInfo) bundleFileInfo.push({ pos, end: writer.getTextPos(), kind: BundleFileSectionKind.NoDefaultLib });
|
||||
writeLine();
|
||||
}
|
||||
if (currentSourceFile && currentSourceFile.moduleName) {
|
||||
@@ -2959,19 +2959,19 @@ namespace ts {
|
||||
for (const directive of files) {
|
||||
const pos = writer.getTextPos();
|
||||
writeComment(`/// <reference path="${directive.fileName}" />`);
|
||||
if (fileBundleInfo) fileBundleInfo.push({ pos, end: writer.getTextPos(), kind: BundleFileSectionKind.Reference, fileName: directive.fileName });
|
||||
if (bundleFileInfo) bundleFileInfo.push({ pos, end: writer.getTextPos(), kind: BundleFileSectionKind.Reference, fileName: directive.fileName });
|
||||
writeLine();
|
||||
}
|
||||
for (const directive of types) {
|
||||
const pos = writer.getTextPos();
|
||||
writeComment(`/// <reference types="${directive.fileName}" />`);
|
||||
if (fileBundleInfo) fileBundleInfo.push({ pos, end: writer.getTextPos(), kind: BundleFileSectionKind.Type, fileName: directive.fileName });
|
||||
if (bundleFileInfo) bundleFileInfo.push({ pos, end: writer.getTextPos(), kind: BundleFileSectionKind.Type, fileName: directive.fileName });
|
||||
writeLine();
|
||||
}
|
||||
for (const directive of libs) {
|
||||
const pos = writer.getTextPos();
|
||||
writeComment(`/// <reference lib="${directive.fileName}" />`);
|
||||
if (fileBundleInfo) fileBundleInfo.push({ pos, end: writer.getTextPos(), kind: BundleFileSectionKind.Lib, fileName: directive.fileName });
|
||||
if (bundleFileInfo) bundleFileInfo.push({ pos, end: writer.getTextPos(), kind: BundleFileSectionKind.Lib, fileName: directive.fileName });
|
||||
writeLine();
|
||||
}
|
||||
}
|
||||
@@ -3015,7 +3015,7 @@ namespace ts {
|
||||
writeLine();
|
||||
const pos = writer.getTextPos();
|
||||
emit(statement);
|
||||
if (fileBundleInfo) fileBundleInfo.push({ pos, end: writer.getTextPos(), kind: BundleFileSectionKind.Prologue, text: statement.expression.text });
|
||||
if (bundleFileInfo) bundleFileInfo.push({ pos, end: writer.getTextPos(), kind: BundleFileSectionKind.Prologue, text: statement.expression.text });
|
||||
if (seenPrologueDirectives) {
|
||||
seenPrologueDirectives.set(statement.expression.text, true);
|
||||
}
|
||||
@@ -3036,7 +3036,7 @@ namespace ts {
|
||||
writeLine();
|
||||
const pos = writer.getTextPos();
|
||||
emit(prologue);
|
||||
if (fileBundleInfo) fileBundleInfo.push({ pos, end: writer.getTextPos(), kind: BundleFileSectionKind.Prologue, text: prologue.text });
|
||||
if (bundleFileInfo) bundleFileInfo.push({ pos, end: writer.getTextPos(), kind: BundleFileSectionKind.Prologue, text: prologue.text });
|
||||
if (seenPrologueDirectives) {
|
||||
seenPrologueDirectives.set(prologue.text, true);
|
||||
}
|
||||
|
||||
@@ -2673,7 +2673,7 @@ namespace ts {
|
||||
sourceMapText: { get() { return mapPathOrType === "js" ? textOrInputFiles.javascriptMapText : textOrInputFiles.declarationMapText; } },
|
||||
});
|
||||
|
||||
const sections = textOrInputFiles.bundleInfo ? mapPathOrType === "js" ? textOrInputFiles.bundleInfo.js : textOrInputFiles.bundleInfo.dts : undefined;
|
||||
const sections = textOrInputFiles.buildInfo ? mapPathOrType === "js" ? textOrInputFiles.buildInfo.js : textOrInputFiles.buildInfo.dts : undefined;
|
||||
if (sections) {
|
||||
for (const section of sections) {
|
||||
switch (section.kind) {
|
||||
@@ -2734,7 +2734,7 @@ namespace ts {
|
||||
javascriptMapPath: string | undefined,
|
||||
declarationPath: string,
|
||||
declarationMapPath: string | undefined,
|
||||
bundleInfoPath: string | undefined
|
||||
buildInfoPath: string | undefined
|
||||
): InputFiles;
|
||||
export function createInputFiles(
|
||||
javascriptText: string,
|
||||
@@ -2750,7 +2750,7 @@ namespace ts {
|
||||
javascriptMapPath?: string,
|
||||
javascriptMapTextOrDeclarationPath?: string,
|
||||
declarationMapPath?: string,
|
||||
declarationMapTextOrBundleInfoPath?: string
|
||||
declarationMapTextOrBuildInfoPath?: string
|
||||
): InputFiles {
|
||||
const node = <InputFiles>createNode(SyntaxKind.InputFiles);
|
||||
if (!isString(javascriptTextOrReadFileText)) {
|
||||
@@ -2770,19 +2770,19 @@ namespace ts {
|
||||
};
|
||||
const jsonGetter = (path: string | undefined) => {
|
||||
const result = textGetter(path);
|
||||
return result !== undefined ? JSON.parse(result) as BundleInfo : undefined;
|
||||
return result !== undefined ? JSON.parse(result) as BuildInfo : undefined;
|
||||
};
|
||||
node.javascriptPath = declarationTextOrJavascriptPath;
|
||||
node.javascriptMapPath = javascriptMapPath;
|
||||
node.declarationPath = Debug.assertDefined(javascriptMapTextOrDeclarationPath);
|
||||
node.declarationMapPath = declarationMapPath;
|
||||
node.bundleInfoPath = declarationMapTextOrBundleInfoPath;
|
||||
node.buildInfoPath = declarationMapTextOrBuildInfoPath;
|
||||
Object.defineProperties(node, {
|
||||
javascriptText: { get() { return definedTextGetter(declarationTextOrJavascriptPath); } },
|
||||
javascriptMapText: { get() { return textGetter(javascriptMapPath); } }, // TODO:: if there is inline sourceMap in jsFile, use that
|
||||
declarationText: { get() { return definedTextGetter(Debug.assertDefined(javascriptMapTextOrDeclarationPath)); } },
|
||||
declarationMapText: { get() { return textGetter(declarationMapPath); } }, // TODO:: if there is inline sourceMap in dtsFile, use that
|
||||
bundleInfo: { get() { return jsonGetter(declarationMapTextOrBundleInfoPath); } }
|
||||
buildInfo: { get() { return jsonGetter(declarationMapTextOrBuildInfoPath); } }
|
||||
});
|
||||
}
|
||||
else {
|
||||
@@ -2791,7 +2791,7 @@ namespace ts {
|
||||
node.javascriptMapText = javascriptMapTextOrDeclarationPath;
|
||||
node.declarationText = declarationTextOrJavascriptPath;
|
||||
node.declarationMapPath = declarationMapPath;
|
||||
node.declarationMapText = declarationMapTextOrBundleInfoPath;
|
||||
node.declarationMapText = declarationMapTextOrBuildInfoPath;
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
@@ -1456,12 +1456,12 @@ namespace ts {
|
||||
// Upstream project didn't have outFile set -- skip (error will have been issued earlier)
|
||||
if (!out) continue;
|
||||
|
||||
const { jsFilePath, sourceMapFilePath, declarationFilePath, declarationMapPath, bundleInfoPath } = getOutputPathsForBundle(resolvedRefOpts.options, /*forceDtsPaths*/ true);
|
||||
const { jsFilePath, sourceMapFilePath, declarationFilePath, declarationMapPath, buildInfoPath } = getOutputPathsForBundle(resolvedRefOpts.options, /*forceDtsPaths*/ true);
|
||||
const node = createInputFiles(fileName => {
|
||||
const path = toPath(fileName);
|
||||
const sourceFile = getSourceFileByPath(path);
|
||||
return sourceFile ? sourceFile.text : filesByName.has(path) ? undefined : host.readFile(path);
|
||||
}, jsFilePath! , sourceMapFilePath, declarationFilePath! , declarationMapPath, bundleInfoPath);
|
||||
}, jsFilePath! , sourceMapFilePath, declarationFilePath! , declarationMapPath, buildInfoPath);
|
||||
nodes.push(node);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -289,9 +289,9 @@ namespace ts {
|
||||
return outputs;
|
||||
}
|
||||
|
||||
function getOutFileOutputs(project: ParsedCommandLine, ignoreBundleInfo?: boolean): ReadonlyArray<string> {
|
||||
function getOutFileOutputs(project: ParsedCommandLine, ignoreBuildInfo?: boolean): ReadonlyArray<string> {
|
||||
Debug.assert(!!project.options.outFile || !!project.options.out, "outFile must be set");
|
||||
const { jsFilePath, sourceMapFilePath, declarationFilePath, declarationMapPath, bundleInfoPath } = getOutputPathsForBundle(project.options, /*forceDtsPaths*/ false);
|
||||
const { jsFilePath, sourceMapFilePath, declarationFilePath, declarationMapPath, buildInfoPath } = getOutputPathsForBundle(project.options, /*forceDtsPaths*/ false);
|
||||
|
||||
let outputs: string[] | undefined = [];
|
||||
const addOutput = (path: string | undefined) => path && (outputs || (outputs = [])).push(path);
|
||||
@@ -299,7 +299,7 @@ namespace ts {
|
||||
addOutput(sourceMapFilePath);
|
||||
addOutput(declarationFilePath);
|
||||
addOutput(declarationMapPath);
|
||||
if (!ignoreBundleInfo) addOutput(bundleInfoPath);
|
||||
if (!ignoreBuildInfo) addOutput(buildInfoPath);
|
||||
return outputs || emptyArray;
|
||||
}
|
||||
|
||||
@@ -711,8 +711,8 @@ namespace ts {
|
||||
}
|
||||
|
||||
// Collect the expected outputs of this project
|
||||
// Do not use presence or absence of bundleInfo to determine status of build
|
||||
const outputs = getAllProjectOutputs(project, /*ignoreBundleInfo*/ true);
|
||||
// Do not use presence or absence of buildInfo to determine status of build
|
||||
const outputs = getAllProjectOutputs(project, /*ignoreBuildInfo*/ true);
|
||||
|
||||
if (outputs.length === 0) {
|
||||
return {
|
||||
@@ -1393,9 +1393,9 @@ namespace ts {
|
||||
return combinePaths(project, "tsconfig.json") as ResolvedConfigFileName;
|
||||
}
|
||||
|
||||
export function getAllProjectOutputs(project: ParsedCommandLine, ignoreBundleInfo?: true): ReadonlyArray<string> {
|
||||
export function getAllProjectOutputs(project: ParsedCommandLine, ignoreBuildInfo?: true): ReadonlyArray<string> {
|
||||
if (project.options.outFile || project.options.out) {
|
||||
return getOutFileOutputs(project, ignoreBundleInfo);
|
||||
return getOutFileOutputs(project, ignoreBuildInfo);
|
||||
}
|
||||
else {
|
||||
const outputs: string[] = [];
|
||||
|
||||
@@ -2770,8 +2770,8 @@ namespace ts {
|
||||
declarationText: string;
|
||||
declarationMapPath?: string;
|
||||
declarationMapText?: string;
|
||||
bundleInfoPath?: string;
|
||||
/*@internal*/ bundleInfo?: BundleInfo;
|
||||
buildInfoPath?: string;
|
||||
/*@internal*/ buildInfo?: BuildInfo;
|
||||
}
|
||||
|
||||
export interface UnparsedSource extends Node {
|
||||
@@ -5428,7 +5428,7 @@ namespace ts {
|
||||
/*@internal*/ writeNode(hint: EmitHint, node: Node, sourceFile: SourceFile | undefined, writer: EmitTextWriter): void;
|
||||
/*@internal*/ writeList<T extends Node>(format: ListFormat, list: NodeArray<T> | undefined, sourceFile: SourceFile | undefined, writer: EmitTextWriter): void;
|
||||
/*@internal*/ writeFile(sourceFile: SourceFile, writer: EmitTextWriter, sourceMapGenerator: SourceMapGenerator | undefined): void;
|
||||
/*@internal*/ writeBundle(bundle: Bundle, info: FileBundleInfo | undefined, writer: EmitTextWriter, sourceMapGenerator: SourceMapGenerator | undefined): void;
|
||||
/*@internal*/ writeBundle(bundle: Bundle, bundleFileInfo: BundleFileInfo | undefined, writer: EmitTextWriter, sourceMapGenerator: SourceMapGenerator | undefined): void;
|
||||
}
|
||||
|
||||
/*@internal*/
|
||||
@@ -5481,11 +5481,11 @@ namespace ts {
|
||||
BundleFileHasNoDefaultLib | BundleFileReference | BundleFileText;
|
||||
|
||||
/*@internal*/
|
||||
export type FileBundleInfo = BundleFileSection[];
|
||||
export type BundleFileInfo = BundleFileSection[];
|
||||
/* @internal */
|
||||
export interface BundleInfo {
|
||||
js?: FileBundleInfo;
|
||||
dts?: FileBundleInfo;
|
||||
export interface BuildInfo {
|
||||
js?: BundleFileInfo;
|
||||
dts?: BundleFileInfo;
|
||||
}
|
||||
|
||||
export interface PrintHandlers {
|
||||
|
||||
@@ -3364,7 +3364,7 @@ namespace ts {
|
||||
sourceMapFilePath: string | undefined;
|
||||
declarationFilePath: string | undefined;
|
||||
declarationMapPath: string | undefined;
|
||||
bundleInfoPath: string | undefined;
|
||||
buildInfoPath: string | undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -472,14 +472,14 @@ export const b = new A();`);
|
||||
"/src/first/bin/first-output.js.map",
|
||||
"/src/first/bin/first-output.d.ts",
|
||||
"/src/first/bin/first-output.d.ts.map",
|
||||
"/src/first/bin/first-output.tsbundleinfo"
|
||||
"/src/first/bin/.tsbuildinfo"
|
||||
],
|
||||
[
|
||||
"/src/2/second-output.js",
|
||||
"/src/2/second-output.js.map",
|
||||
"/src/2/second-output.d.ts",
|
||||
"/src/2/second-output.d.ts.map",
|
||||
"/src/2/second-output.tsbundleinfo"
|
||||
"/src/2/.tsbuildinfo"
|
||||
],
|
||||
[
|
||||
"/src/third/thirdjs/output/third-output.js",
|
||||
@@ -489,8 +489,8 @@ export const b = new A();`);
|
||||
]
|
||||
];
|
||||
|
||||
function verifyOutFileScenarioWorker(scenario: string, modifyFs: (fs: vfs.FileSystem) => void | ReadonlyArray<string>, withoutBundleInfo: boolean) {
|
||||
describe(`unittests:: tsbuild - outFile:: ${scenario}${withoutBundleInfo ? " without bundleInfo" : ""}`, () => {
|
||||
function verifyOutFileScenarioWorker(scenario: string, modifyFs: (fs: vfs.FileSystem) => void | ReadonlyArray<string>, withoutBuildInfo: boolean) {
|
||||
describe(`unittests:: tsbuild - outFile:: ${scenario}${withoutBuildInfo ? " without build info" : ""}`, () => {
|
||||
let fs: vfs.FileSystem | undefined;
|
||||
const actualReadFileMap = createMap<number>();
|
||||
let additionalSourceFiles: ReadonlyArray<string> | void;
|
||||
@@ -506,12 +506,12 @@ export const b = new A();`);
|
||||
if (path.startsWith("/src/")) {
|
||||
actualReadFileMap.set(path, (actualReadFileMap.get(path) || 0) + 1);
|
||||
}
|
||||
if (withoutBundleInfo && getBaseFileName(path) === infoFile) {
|
||||
if (withoutBuildInfo && getBaseFileName(path) === infoFile) {
|
||||
return undefined;
|
||||
}
|
||||
return originalReadFile.call(host, path);
|
||||
};
|
||||
if (withoutBundleInfo) {
|
||||
if (withoutBuildInfo) {
|
||||
const originalWriteFile = host.writeFile;
|
||||
host.writeFile = (fileName, content, writeByteOrder) => {
|
||||
return getBaseFileName(fileName) !== infoFile &&
|
||||
@@ -539,7 +539,7 @@ export const b = new A();`);
|
||||
|
||||
const patch = fs!.diff();
|
||||
// tslint:disable-next-line:no-null-keyword
|
||||
Harness.Baseline.runBaseline(`outFile-${scenario.split(" ").join("-")}${withoutBundleInfo ? "-no-bundleInfo" : ""}.js`, patch ? vfs.formatPatch(patch) : null);
|
||||
Harness.Baseline.runBaseline(`outFile-${scenario.split(" ").join("-")}${withoutBuildInfo ? "-no-buildInfo" : ""}.js`, patch ? vfs.formatPatch(patch) : null);
|
||||
});
|
||||
it("verify readFile calls", () => {
|
||||
const expected = [
|
||||
@@ -574,8 +574,8 @@ export const b = new A();`);
|
||||
}
|
||||
|
||||
function verifyOutFileScenario(scenario: string, modifyFs: (fs: vfs.FileSystem) => void | ReadonlyArray<string>) {
|
||||
verifyOutFileScenarioWorker(scenario, modifyFs, /*withoutBundleInfo*/ false);
|
||||
verifyOutFileScenarioWorker(scenario, modifyFs, /*withoutBundleInfo*/ true);
|
||||
verifyOutFileScenarioWorker(scenario, modifyFs, /*withoutBuildInfo*/ false);
|
||||
verifyOutFileScenarioWorker(scenario, modifyFs, /*withoutBuildInfo*/ true);
|
||||
}
|
||||
|
||||
verifyOutFileScenario("baseline sectioned sourcemaps", noop);
|
||||
@@ -621,7 +621,7 @@ export const b = new A();`);
|
||||
builder.cleanAllProjects();
|
||||
});
|
||||
|
||||
it("unittests:: tsbuild - outFile:: verify tsbundleInfo presence or absence does not result in new build", () => {
|
||||
it("unittests:: tsbuild - outFile:: verify buildInfo presence or absence does not result in new build", () => {
|
||||
const fs = outFileFs.shadow();
|
||||
const expectedOutputs = [
|
||||
...outputFiles[0],
|
||||
|
||||
Reference in New Issue
Block a user