Handle emit when using prepends and the referencing project has --stripInternal true

This commit is contained in:
Sheetal Nandi
2019-02-20 10:41:28 -08:00
parent a0f3420001
commit 0cd7074e1b
9 changed files with 472 additions and 1621 deletions
+59 -16
View File
@@ -260,7 +260,8 @@ namespace ts {
inlineSourceMap: compilerOptions.inlineSourceMap,
extendedDiagnostics: compilerOptions.extendedDiagnostics,
onlyPrintJsDocStyle: true,
writeBundleFileInfo: !!bundleBuildInfo
writeBundleFileInfo: !!bundleBuildInfo,
recordInternalSection: !!bundleBuildInfo
};
const declarationPrinter = createPrinter(printerOptions, {
@@ -528,12 +529,14 @@ namespace ts {
const sourceMapText = sourceMapFilePath && host.readFile(sourceMapFilePath);
// error if no source map or for now if inline sourcemap
if ((sourceMapFilePath && !sourceMapText) || config.options.inlineSourceMap) return sourceMapFilePath || "inline sourcemap decoding";
const stripInternal = config.options.stripInternal;
const declarationMapText = declarationMapPath && host.readFile(declarationMapPath);
// error if no source map or for now if inline sourcemap
if ((declarationMapPath && !declarationMapText) || config.options.inlineSourceMap) return declarationMapPath || "inline sourcemap decoding";
// read declaration text
const declarationText = declarationMapText && host.readFile(declarationFilePath!);
if (declarationMapText && !declarationText) return declarationFilePath!;
const shouldHaveDeclarationText = stripInternal || declarationMapText;
const declarationText = shouldHaveDeclarationText && host.readFile(declarationFilePath!);
if (shouldHaveDeclarationText && !declarationText) return declarationFilePath!;
const buildInfo = JSON.parse(buildInfoText) as BuildInfo;
if (!buildInfo.bundle || !buildInfo.bundle.js || (declarationMapText && !buildInfo.bundle.dts)) return buildInfoPath!;
@@ -593,14 +596,22 @@ namespace ts {
// Emit js
emitFiles(notImplementedResolver, emitHost, /*targetSourceFile*/ undefined, /*emitOnlyDtsFiles*/ false, getTransformers(optionsWithoutDeclaration));
// Emit d.ts map
if (declarationMapText) {
emitHost.getPrependNodes = memoize(() => [createUnparsedDtsSourceFileWithPrepend(ownPrependInput, prependNodes)]);
if (shouldHaveDeclarationText) {
emitHost.getPrependNodes = memoize(() => [createUnparsedDtsSourceFileWithPrepend(ownPrependInput, prependNodes, stripInternal)]);
emitHost.getCompilerOptions = () => config.options;
emitHost.getSourceFiles = () => emptyArray;
emitHost.writeFile = (name, text, writeByteOrderMark) => {
// Same dts ignore
if (fileExtensionIs(name, Extension.Dts) || name === buildInfoPath) return;
outputFiles.push({ name, text, writeByteOrderMark });
if (!stripInternal && (fileExtensionIs(name, Extension.Dts) || name === buildInfoPath)) return;
// Even though dts file hasnt changed, whether def is internal or not could change, so write the dts and update buildInfo
if (name !== buildInfo) {
outputFiles.push({ name, text, writeByteOrderMark });
}
else {
const buildInfo = JSON.parse(text) as BuildInfo;
newBundle.dts = buildInfo.bundle && buildInfo.bundle.dts;
writeByteOrderMarkBuildInfo = writeByteOrderMarkBuildInfo || writeByteOrderMark;
}
};
emitFiles(notImplementedResolver, emitHost, /*targetSourceFile*/ undefined, /*emitOnlyDtsFiles*/ true);
}
@@ -646,6 +657,8 @@ namespace ts {
let write = writeBase;
let isOwnFileEmit: boolean;
const bundleFileInfo = printerOptions.writeBundleFileInfo ? { sections: [] } as BundleFileInfo : undefined;
const recordInternalSection = printerOptions.recordInternalSection;
let sourceFileTextPos = 0;
// Source Maps
let sourceMapsDisabled = true;
@@ -748,6 +761,24 @@ namespace ts {
return writer.getTextPosWithWriteLine ? writer.getTextPosWithWriteLine() : writer.getTextPos();
}
function updateOrPushBundleFileTextLike(pos: number, end: number, kind: BundleFileTextLikeKind) {
const last = lastOrUndefined(bundleFileInfo!.sections);
if (last && last.kind === kind) {
last.end = end;
}
else {
bundleFileInfo!.sections.push({ pos, end, kind });
}
}
function recordBundleFileTextSection(end: number) {
if (sourceFileTextPos < end) {
updateOrPushBundleFileTextLike(sourceFileTextPos, end, BundleFileSectionKind.Text);
return true;
}
return false;
}
function writeBundle(bundle: Bundle, output: EmitTextWriter, sourceMapGenerator: SourceMapGenerator | undefined) {
isOwnFileEmit = false;
const previousWriter = writer;
@@ -774,14 +805,13 @@ namespace ts {
}
}
const pos = getTextPosWithWriteLine();
sourceFileTextPos = getTextPosWithWriteLine();
for (const sourceFile of bundle.sourceFiles) {
print(EmitHint.SourceFile, sourceFile, sourceFile);
}
if (bundleFileInfo && bundle.sourceFiles.length) {
const end = writer.getTextPos();
if (pos !== end) {
bundleFileInfo.sections.push({ pos, end: writer.getTextPos(), kind: BundleFileSectionKind.Text });
if (recordBundleFileTextSection(end)) {
// Store prologues
const prologues = getPrologueDirectivesFromBundledSourceFiles(bundle);
if (prologues) {
@@ -882,8 +912,15 @@ namespace ts {
function emit(node: Node | undefined) {
if (node === undefined) return;
const end = writer.getTextPos();
const pos = getTextPosWithWriteLine();
const pipelinePhase = getPipelinePhase(PipelinePhase.Notification, node);
pipelinePhase(EmitHint.Unspecified, node);
if (recordInternalSection && bundleFileInfo && currentSourceFile && (isDeclaration(node) || isVariableStatement(node)) && isInternalDeclaration(node, currentSourceFile)) {
recordBundleFileTextSection(end);
updateOrPushBundleFileTextLike(pos, writer.getTextPos(), BundleFileSectionKind.Internal);
sourceFileTextPos = getTextPosWithWriteLine();
}
}
function emitIdentifierName(node: Identifier | undefined) {
@@ -967,6 +1004,7 @@ namespace ts {
return writeUnparsedNode(<UnparsedNode>node);
case SyntaxKind.UnparsedText:
case SyntaxKind.UnparsedInternalText:
case SyntaxKind.UnparsedSourceMapUrl:
return emitUnparsedTextLike(<UnparsedTextLike>node);
@@ -1491,24 +1529,29 @@ namespace ts {
// SyntaxKind.UnparsedPrologue
// SyntaxKind.UnparsedText
// SyntaxKind.UnparsedInternalText
// SyntaxKind.UnparsedSourceMapUrl
// SyntaxKind.UnparsedSectionText
function writeUnparsedNode(unparsed: UnparsedNode) {
writer.rawWrite(unparsed.parent.text.substring(unparsed.pos, unparsed.end));
}
// SyntaxKind.UnparsedText
// SyntaxKind.UnparsedInternalText
// SyntaxKind.UnparsedSourceMapUrl
function emitUnparsedTextLike(unparsed: UnparsedTextLike) {
const pos = getTextPosWithWriteLine();
writeUnparsedNode(unparsed);
if (bundleFileInfo) {
bundleFileInfo.sections.push({
updateOrPushBundleFileTextLike(
pos,
end: writer.getTextPos(),
kind: unparsed.kind === SyntaxKind.UnparsedText ?
BundleFileSectionKind.Text
: BundleFileSectionKind.SourceMapUrl
});
writer.getTextPos(),
unparsed.kind === SyntaxKind.UnparsedText ?
BundleFileSectionKind.Text :
unparsed.kind === SyntaxKind.UnparsedInternalText ?
BundleFileSectionKind.Internal :
BundleFileSectionKind.SourceMapUrl
);
}
}
+21 -13
View File
@@ -2663,9 +2663,9 @@ namespace ts {
}
export function createUnparsedSourceFile(text: string): UnparsedSource;
export function createUnparsedSourceFile(inputFile: InputFiles, type: "js" | "dts"): UnparsedSource;
export function createUnparsedSourceFile(inputFile: InputFiles, type: "js" | "dts", stripInternal?: boolean): UnparsedSource;
export function createUnparsedSourceFile(text: string, mapPath: string | undefined, map: string | undefined): UnparsedSource;
export function createUnparsedSourceFile(textOrInputFiles: string | InputFiles, mapPathOrType?: string, mapText?: string): UnparsedSource {
export function createUnparsedSourceFile(textOrInputFiles: string | InputFiles, mapPathOrType?: string, mapTextOrStripInternal?: string | boolean): UnparsedSource {
const node = createUnparsedSource();
let prologues: UnparsedPrologue[] | undefined;
let helpers: UnscopedEmitHelper[] | undefined;
@@ -2684,6 +2684,8 @@ namespace ts {
});
if (textOrInputFiles.buildInfo && textOrInputFiles.buildInfo.bundle) {
Debug.assert(mapTextOrStripInternal === undefined || typeof mapTextOrStripInternal === "boolean");
const stripInternal = mapTextOrStripInternal as boolean | undefined;
const bundleFileInfo = mapPathOrType === "js" ? textOrInputFiles.buildInfo.bundle.js : textOrInputFiles.buildInfo.bundle.dts;
for (const section of bundleFileInfo ? bundleFileInfo.sections : emptyArray) {
switch (section.kind) {
@@ -2710,9 +2712,12 @@ namespace ts {
prependNode.texts = section.texts.map(text => createUnparsedNode(text, node) as UnparsedTextLike);
(texts || (texts = [])).push(prependNode);
break;
case BundleFileSectionKind.Internal:
if (stripInternal) break;
// falls through
case BundleFileSectionKind.Text:
case BundleFileSectionKind.SourceMapUrl:
(texts || (texts = [])).push(createUnparsedNode(section, node) as UnparsedSourceText);
(texts || (texts = [])).push(createUnparsedNode(section, node) as UnparsedTextLike);
break;
default:
Debug.assertNever(section);
@@ -2724,7 +2729,7 @@ namespace ts {
node.fileName = "";
node.text = textOrInputFiles;
node.sourceMapPath = mapPathOrType;
node.sourceMapText = mapText;
node.sourceMapText = mapTextOrStripInternal as string;
}
node.prologues = prologues || emptyArray;
node.helpers = helpers;
@@ -2748,11 +2753,11 @@ namespace ts {
});
const bundleFileInfo = Debug.assertDefined(input.buildInfo && input.buildInfo.bundle && input.buildInfo.bundle.js);
const texts: UnparsedSourceText[] = [];
const texts: UnparsedTextLike[] = [];
for (const section of bundleFileInfo.sections) {
switch (section.kind) {
case BundleFileSectionKind.Text:
texts.push(createUnparsedNode(section, node) as UnparsedSourceText);
texts.push(createUnparsedNode(section, node) as UnparsedTextLike);
break;
// Ignore
case BundleFileSectionKind.Prologue:
@@ -2764,6 +2769,7 @@ namespace ts {
case BundleFileSectionKind.Reference:
case BundleFileSectionKind.Type:
case BundleFileSectionKind.Lib:
case BundleFileSectionKind.Internal:
Debug.fail(`js shouldnt have section: ${JSON.stringify(section)}`);
break;
default:
@@ -2776,7 +2782,7 @@ namespace ts {
}
/*@internal*/
export function createUnparsedDtsSourceFileWithPrepend(input: InputFiles, prepends: ReadonlyArray<InputFiles>): UnparsedSource {
export function createUnparsedDtsSourceFileWithPrepend(input: InputFiles, prepends: ReadonlyArray<InputFiles>, stripInternal: boolean | undefined): UnparsedSource {
Debug.assert(!!input.oldFileOfCurrentEmit);
const node = createUnparsedSource();
node.oldFileOfCurrentEmit = true;
@@ -2784,7 +2790,7 @@ namespace ts {
node.sourceMapPath = Debug.assertDefined(input.declarationMapPath);
node.text = input.declarationText;
node.sourceMapText = input.declarationMapText;
const mapOfPrepend = arrayToMap(prepends, prepend => prepend.declarationPath!, prepend => createUnparsedSourceFile(prepend, "dts"));
const mapOfPrepend = arrayToMap(prepends, prepend => prepend.declarationPath!, prepend => createUnparsedSourceFile(prepend, "dts", stripInternal));
const texts: UnparsedSourceText[] = [];
const bundleFileInfo = Debug.assertDefined(input.buildInfo && input.buildInfo.bundle && input.buildInfo.bundle.dts);
for (const section of bundleFileInfo.sections) {
@@ -2798,14 +2804,15 @@ namespace ts {
case BundleFileSectionKind.Prepend:
const parent = mapOfPrepend.get(section.data)!;
const sectionNode = createUnparsedSectionText(section, parent);
sectionNode.pos = parent.texts[0].pos;
sectionNode.end = last(parent.texts).end;
texts.push(sectionNode);
const prependNode = createUnparsedNode(section, node) as UnparsedPrepend;
parent.texts.forEach(text => Debug.assert(isUnparsedTextLike(text)));
prependNode.texts = parent.texts as UnparsedTextLike[];
texts.push(prependNode);
break;
case BundleFileSectionKind.Internal:
case BundleFileSectionKind.Text:
texts.push(createUnparsedNode(section, node) as UnparsedSourceText);
texts.push(createUnparsedNode(section, node) as UnparsedTextLike);
break;
// Ignore
@@ -2830,6 +2837,7 @@ namespace ts {
switch (kind) {
case BundleFileSectionKind.Prologue: return SyntaxKind.UnparsedPrologue;
case BundleFileSectionKind.Prepend: return SyntaxKind.UnparsedPrepend;
case BundleFileSectionKind.Internal: return SyntaxKind.UnparsedInternalText;
case BundleFileSectionKind.Text: return SyntaxKind.UnparsedText;
case BundleFileSectionKind.SourceMapUrl: return SyntaxKind.UnparsedSourceMapUrl;
+11 -13
View File
@@ -9,6 +9,15 @@ namespace ts {
return result.diagnostics;
}
export function isInternalDeclaration(node: Node, currentSourceFile: SourceFile) {
const parseTreeNode = getParseTreeNode(node);
const leadingCommentRanges = parseTreeNode && getLeadingCommentRangesOfNode(parseTreeNode, currentSourceFile);
return !!forEach(leadingCommentRanges, range => {
const comment = currentSourceFile.text.substring(range.pos, range.end);
return stringContains(comment, "@internal");
});
}
const declarationEmitNodeBuilderFlags =
NodeBuilderFlags.MultilineObjectLiterals |
NodeBuilderFlags.WriteClassExpressionAsTypeLiteral |
@@ -207,7 +216,7 @@ namespace ts {
}
), mapDefined(node.prepends, prepend => {
if (prepend.kind === SyntaxKind.InputFiles) {
const sourceFile = createUnparsedSourceFile(prepend, "dts");
const sourceFile = createUnparsedSourceFile(prepend, "dts", stripInternal);
hasNoDefaultLib = hasNoDefaultLib || !!sourceFile.hasNoDefaultLib;
collectReferences(sourceFile, refs);
recordTypeReferenceDirectivesIfNecessary(sourceFile.typeReferenceDirectives);
@@ -1228,19 +1237,8 @@ namespace ts {
errorNameNode = undefined;
}
function hasInternalAnnotation(range: CommentRange) {
const comment = currentSourceFile.text.substring(range.pos, range.end);
return stringContains(comment, "@internal");
}
function shouldStripInternal(node: Node) {
if (stripInternal && node) {
const leadingCommentRanges = getLeadingCommentRangesOfNode(getParseTreeNode(node), currentSourceFile);
if (forEach(leadingCommentRanges, hasInternalAnnotation)) {
return true;
}
}
return false;
return !!stripInternal && !!node && isInternalDeclaration(node, currentSourceFile);
}
function isScopeMarker(node: Node) {
+10 -3
View File
@@ -432,6 +432,7 @@ namespace ts {
UnparsedPrologue,
UnparsedPrepend,
UnparsedText,
UnparsedInternalText,
UnparsedSourceMapUrl,
UnparsedSectionText,
@@ -2827,7 +2828,7 @@ namespace ts {
}
export interface UnparsedTextLike extends UnparsedSection {
kind: SyntaxKind.UnparsedText | SyntaxKind.UnparsedSourceMapUrl;
kind: SyntaxKind.UnparsedText | SyntaxKind.UnparsedInternalText | SyntaxKind.UnparsedSourceMapUrl;
parent: UnparsedSource;
}
@@ -5506,8 +5507,9 @@ namespace ts {
Lib = "lib",
Prepend = "prepend",
Text = "text",
Internal = "internal",
SourceMapUrl = "sourceMapUrl",
// internal comments?
// comments?
}
/*@internal*/
@@ -5546,9 +5548,12 @@ namespace ts {
texts: BundleFileTextLike[];
}
/*@internal*/
export type BundleFileTextLikeKind = BundleFileSectionKind.Text | BundleFileSectionKind.Internal | BundleFileSectionKind.SourceMapUrl;
/*@internal*/
export interface BundleFileTextLike extends BundleFileSectionBase {
kind: BundleFileSectionKind.Text | BundleFileSectionKind.SourceMapUrl;
kind: BundleFileTextLikeKind;
}
/*@internal*/
@@ -5665,6 +5670,8 @@ namespace ts {
/*@internal*/ onlyPrintJsDocStyle?: boolean;
/*@internal*/ neverAsciiEscape?: boolean;
/*@internal*/ writeBundleFileInfo?: boolean;
/*@internal*/ recordInternalSection?: boolean;
/*@internal*/ stripInternal?: boolean;
}
/* @internal */
+16 -5
View File
@@ -4605,6 +4605,7 @@ namespace ts {
export function isBundleFileTextLike(section: BundleFileSection): section is BundleFileTextLike {
switch (section.kind) {
case BundleFileSectionKind.Text:
case BundleFileSectionKind.Internal:
case BundleFileSectionKind.SourceMapUrl:
return true;
default:
@@ -6007,12 +6008,22 @@ namespace ts {
return node.kind === SyntaxKind.UnparsedPrepend;
}
export function isUnparsedTextLike(node: Node): node is UnparsedTextLike {
switch (node.kind) {
case SyntaxKind.UnparsedText:
case SyntaxKind.UnparsedInternalText:
case SyntaxKind.UnparsedSourceMapUrl:
return true;
default:
return false;
}
}
export function isUnparsedNode(node: Node): node is UnparsedNode {
return node.kind === SyntaxKind.UnparsedPrologue ||
node.kind === SyntaxKind.UnparsedPrepend ||
node.kind === SyntaxKind.UnparsedText ||
node.kind === SyntaxKind.UnparsedSourceMapUrl ||
node.kind === SyntaxKind.UnparsedSectionText;
return isUnparsedTextLike(node) ||
node.kind === SyntaxKind.UnparsedPrologue ||
node.kind === SyntaxKind.UnparsedSectionText ||
isUnparsedPrepend(node);
}
// JSDoc
+77 -56
View File
@@ -82,7 +82,21 @@ namespace ts {
return ts.createSolutionBuilder(host, ["/src/third"], { dry: false, force: false, verbose: true });
}
function verifyOutFileScenario({ scenario, modifyFs, modifyAgainFs, additionalSourceFiles, dependOrdered }: { scenario: string; modifyFs: (fs: vfs.FileSystem) => void; modifyAgainFs?: (fs: vfs.FileSystem) => void; additionalSourceFiles?: ReadonlyArray<string>; dependOrdered?: boolean }) {
function verifyOutFileScenario({
scenario,
modifyFs,
modifyAgainFs,
additionalSourceFiles,
dependOrdered,
unchangedDtsWritesThirdDts,
}: {
scenario: string;
modifyFs: (fs: vfs.FileSystem) => void;
modifyAgainFs?: (fs: vfs.FileSystem) => void;
additionalSourceFiles?: ReadonlyArray<string>;
dependOrdered?: boolean;
unchangedDtsWritesThirdDts?: boolean;
}) {
const incrementalDtsChanged: ExpectedBuildOutputPerState = {
expectedDiagnostics: dependOrdered ?
[
@@ -144,10 +158,10 @@ namespace ts {
[Diagnostics.Building_project_0, sources[project.first][source.config]],
[Diagnostics.Project_0_is_out_of_date_because_output_javascript_and_source_map_if_specified_of_its_dependency_1_has_changed, relSources[project.second][source.config], "src/first"],
[Diagnostics.Updating_output_javascript_and_javascript_source_map_if_specified_of_project_0, sources[project.second][source.config]],
[Diagnostics.Updating_unchanged_output_timestamps_of_project_0, sources[project.second][source.config]],
...getUnchangedOutputTimeStampUpdate(project.second),
[Diagnostics.Project_0_is_out_of_date_because_output_javascript_and_source_map_if_specified_of_its_dependency_1_has_changed, relSources[project.third][source.config], "src/second"],
[Diagnostics.Updating_output_javascript_and_javascript_source_map_if_specified_of_project_0, sources[project.third][source.config]],
[Diagnostics.Updating_unchanged_output_timestamps_of_project_0, sources[project.third][source.config]]
...getUnchangedOutputTimeStampUpdate(project.third),
] :
[
getExpectedDiagnosticForProjectsInBuild(relSources[project.first][source.config], relSources[project.second][source.config], relSources[project.third][source.config]),
@@ -156,7 +170,7 @@ namespace ts {
[Diagnostics.Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2, relSources[project.second][source.config], relSources[project.second][source.ts][part.one], relOutputFiles[project.second][ext.js]],
[Diagnostics.Project_0_is_out_of_date_because_output_javascript_and_source_map_if_specified_of_its_dependency_1_has_changed, relSources[project.third][source.config], "src/first"],
[Diagnostics.Updating_output_javascript_and_javascript_source_map_if_specified_of_project_0, sources[project.third][source.config]],
[Diagnostics.Updating_unchanged_output_timestamps_of_project_0, sources[project.third][source.config]]
...getUnchangedOutputTimeStampUpdate(project.third),
],
expectedReadFiles: getReadFilesMap(
[
@@ -298,6 +312,12 @@ namespace ts {
withoutBuildInfo: incrementalDtsUnchangedWithoutBuildInfo
}
});
function getUnchangedOutputTimeStampUpdate(project: project): ReadonlyArray<fakes.ExpectedDiagnostic> {
return !unchangedDtsWritesThirdDts ?
[[Diagnostics.Updating_unchanged_output_timestamps_of_project_0, sources[project][source.config]]] :
emptyArray;
}
}
verifyOutFileScenario({
@@ -624,62 +644,63 @@ ${internal} enum internalEnum { a, b, c }`);
verifyOutFileScenario({
scenario: "stripInternal",
modifyFs: fs => stripInternalScenario(fs),
modifyAgainFs: fs => replaceText(fs, sources[project.first][source.ts][part.one], `/*@internal*/ interface`, "interface")
});
verifyOutFileScenario({
scenario: "stripInternal with comments emit enabled",
modifyFs: fs => stripInternalScenario(fs, /*removeCommentsDisabled*/ true),
modifyAgainFs: fs => replaceText(fs, sources[project.first][source.ts][part.one], `/*@internal*/ interface`, "interface")
});
verifyOutFileScenario({
scenario: "stripInternal jsdoc style comment",
modifyFs: fs => stripInternalScenario(fs, /*removeCommentsDisabled*/ false, /*jsDocStyle*/ true),
modifyAgainFs: fs => replaceText(fs, sources[project.first][source.ts][part.one], `/**@internal*/ interface`, "interface")
});
verifyOutFileScenario({
scenario: "stripInternal jsdoc style with comments emit enabled",
modifyFs: fs => stripInternalScenario(fs, /*removeCommentsDisabled*/ true, /*jsDocStyle*/ true),
});
function makeOneTwoThreeDependOrder(fs: vfs.FileSystem) {
replaceText(fs, sources[project.second][source.config], "[", `[
{ "path": "../first", "prepend": true }`);
replaceText(fs, sources[project.third][source.config], `{ "path": "../first", "prepend": true },`, "");
}
function stripInternalWithDependentOrder(fs: vfs.FileSystem, removeCommentsDisabled?: boolean, jsDocStyle?: boolean) {
stripInternalScenario(fs, removeCommentsDisabled, jsDocStyle);
makeOneTwoThreeDependOrder(fs);
}
verifyOutFileScenario({
scenario: "stripInternal when one-two-three are prepended in order",
modifyFs: fs => stripInternalWithDependentOrder(fs),
modifyAgainFs: fs => replaceText(fs, sources[project.first][source.ts][part.one], `/*@internal*/ interface`, "interface"),
dependOrdered: true
unchangedDtsWritesThirdDts: true
});
verifyOutFileScenario({
scenario: "stripInternal with comments emit enabled when one-two-three are prepended in order",
modifyFs: fs => stripInternalWithDependentOrder(fs, /*removeCommentsDisabled*/ true),
modifyAgainFs: fs => replaceText(fs, sources[project.first][source.ts][part.one], `/*@internal*/ interface`, "interface"),
dependOrdered: true
});
// verifyOutFileScenario({
// scenario: "stripInternal with comments emit enabled",
// modifyFs: fs => stripInternalScenario(fs, /*removeCommentsDisabled*/ true),
// modifyAgainFs: fs => replaceText(fs, sources[project.first][source.ts][part.one], `/*@internal*/ interface`, "interface")
// });
verifyOutFileScenario({
scenario: "stripInternal jsdoc style comment when one-two-three are prepended in order",
modifyFs: fs => stripInternalWithDependentOrder(fs, /*removeCommentsDisabled*/ false, /*jsDocStyle*/ true),
modifyAgainFs: fs => replaceText(fs, sources[project.first][source.ts][part.one], `/**@internal*/ interface`, "interface"),
dependOrdered: true
});
// verifyOutFileScenario({
// scenario: "stripInternal jsdoc style comment",
// modifyFs: fs => stripInternalScenario(fs, /*removeCommentsDisabled*/ false, /*jsDocStyle*/ true),
// modifyAgainFs: fs => replaceText(fs, sources[project.first][source.ts][part.one], `/**@internal*/ interface`, "interface")
// });
verifyOutFileScenario({
scenario: "stripInternal jsdoc style with comments emit enabled when one-two-three are prepended in order",
modifyFs: fs => stripInternalWithDependentOrder(fs, /*removeCommentsDisabled*/ true, /*jsDocStyle*/ true),
dependOrdered: true
});
// verifyOutFileScenario({
// scenario: "stripInternal jsdoc style with comments emit enabled",
// modifyFs: fs => stripInternalScenario(fs, /*removeCommentsDisabled*/ true, /*jsDocStyle*/ true),
// });
// function makeOneTwoThreeDependOrder(fs: vfs.FileSystem) {
// replaceText(fs, sources[project.second][source.config], "[", `[
//{ "path": "../first", "prepend": true }`);
// replaceText(fs, sources[project.third][source.config], `{ "path": "../first", "prepend": true },`, "");
// }
// function stripInternalWithDependentOrder(fs: vfs.FileSystem, removeCommentsDisabled?: boolean, jsDocStyle?: boolean) {
// stripInternalScenario(fs, removeCommentsDisabled, jsDocStyle);
// makeOneTwoThreeDependOrder(fs);
// }
// verifyOutFileScenario({
// scenario: "stripInternal when one-two-three are prepended in order",
// modifyFs: fs => stripInternalWithDependentOrder(fs),
// modifyAgainFs: fs => replaceText(fs, sources[project.first][source.ts][part.one], `/*@internal*/ interface`, "interface"),
// dependOrdered: true
// });
// verifyOutFileScenario({
// scenario: "stripInternal with comments emit enabled when one-two-three are prepended in order",
// modifyFs: fs => stripInternalWithDependentOrder(fs, /*removeCommentsDisabled*/ true),
// modifyAgainFs: fs => replaceText(fs, sources[project.first][source.ts][part.one], `/*@internal*/ interface`, "interface"),
// dependOrdered: true
// });
// verifyOutFileScenario({
// scenario: "stripInternal jsdoc style comment when one-two-three are prepended in order",
// modifyFs: fs => stripInternalWithDependentOrder(fs, /*removeCommentsDisabled*/ false, /*jsDocStyle*/ true),
// modifyAgainFs: fs => replaceText(fs, sources[project.first][source.ts][part.one], `/**@internal*/ interface`, "interface"),
// dependOrdered: true
// });
// verifyOutFileScenario({
// scenario: "stripInternal jsdoc style with comments emit enabled when one-two-three are prepended in order",
// modifyFs: fs => stripInternalWithDependentOrder(fs, /*removeCommentsDisabled*/ true, /*jsDocStyle*/ true),
// dependOrdered: true
// });
});
}
@@ -20,6 +20,11 @@
"sections": [
{
"pos": 0,
"end": 39,
"kind": "internal"
},
{
"pos": 41,
"end": 157,
"kind": "text"
},
@@ -53,10 +58,12 @@ sourceMapUrl: (127-167)
======================================================================
File:: /src/first/bin/first-output.d.ts
----------------------------------------------------------------------
text: (0-157)
internal: (0-39)
interface TheFirst {
none: any;
}
----------------------------------------------------------------------
text: (41-157)
declare const s = "Hello, world";
interface NoJsForHereEither {
none: any;
@@ -325,48 +332,48 @@ console.log(s);
"sections": [
{
"pos": 0,
"end": 199,
"end": 158,
"kind": "prepend",
"data": "/src/first/bin/first-output.d.ts",
"texts": [
{
"pos": 0,
"end": 157,
"end": 116,
"kind": "text"
},
{
"pos": 157,
"end": 199,
"pos": 116,
"end": 158,
"kind": "sourceMapUrl"
}
]
},
{
"pos": 201,
"end": 1289,
"pos": 160,
"end": 363,
"kind": "prepend",
"data": "/src/2/second-output.d.ts",
"texts": [
{
"pos": 201,
"end": 1246,
"pos": 160,
"end": 320,
"kind": "text"
},
{
"pos": 1246,
"end": 1289,
"pos": 320,
"end": 363,
"kind": "sourceMapUrl"
}
]
},
{
"pos": 1291,
"end": 1310,
"pos": 365,
"end": 384,
"kind": "text"
},
{
"pos": 1310,
"end": 1352,
"pos": 384,
"end": 426,
"kind": "sourceMapUrl"
}
]
@@ -514,12 +521,9 @@ sourceMapUrl: (3300-3340)
======================================================================
File:: /src/third/thirdjs/output/third-output.d.ts
----------------------------------------------------------------------
prepend: (0-199):: /src/first/bin/first-output.d.ts texts:: 2
prepend: (0-158):: /src/first/bin/first-output.d.ts texts:: 2
>>--------------------------------------------------------------------
text: (0-157)
interface TheFirst {
none: any;
}
text: (0-116)
declare const s = "Hello, world";
interface NoJsForHereEither {
none: any;
@@ -527,75 +531,33 @@ interface NoJsForHereEither {
declare function f(): string;
>>--------------------------------------------------------------------
sourceMapUrl: (157-199)
sourceMapUrl: (116-158)
//# sourceMappingURL=first-output.d.ts.map
----------------------------------------------------------------------
prepend: (201-1289):: /src/2/second-output.d.ts texts:: 2
prepend: (160-363):: /src/2/second-output.d.ts texts:: 2
>>--------------------------------------------------------------------
text: (201-1246)
text: (160-320)
declare namespace N {
}
declare namespace N {
}
declare class normalC {
constructor();
prop: string;
method(): void;
c: number;
}
declare namespace normalN {
class C {
}
function foo(): void;
namespace someNamespace {
class C {
}
}
namespace someOther.something {
class someClass {
}
}
export import someImport = someNamespace.C;
type internalType = internalC;
const internalConst = 10;
enum internalEnum {
a = 0,
b = 1,
c = 2
}
}
declare class internalC {
}
declare function internalfoo(): void;
declare namespace internalNamespace {
class someClass {
}
}
declare namespace internalOther.something {
class someClass {
}
}
import internalImport = internalNamespace.someClass;
declare type internalType = internalC;
declare const internalConst = 10;
declare enum internalEnum {
a = 0,
b = 1,
c = 2
}
declare class C {
doSomething(): void;
}
>>--------------------------------------------------------------------
sourceMapUrl: (1246-1289)
sourceMapUrl: (320-363)
//# sourceMappingURL=second-output.d.ts.map
----------------------------------------------------------------------
text: (1291-1310)
text: (365-384)
declare var c: C;
----------------------------------------------------------------------
sourceMapUrl: (1310-1352)
sourceMapUrl: (384-426)
//# sourceMappingURL=third-output.d.ts.map
======================================================================