Ensure prepend texts are set when skipping internals (#33694)

This commit is contained in:
Ron Buckton
2019-10-01 12:33:17 -07:00
committed by GitHub
parent a04f1eb7f0
commit 526ed5284e
4 changed files with 352 additions and 2 deletions
+4 -1
View File
@@ -2974,7 +2974,10 @@ namespace ts {
(texts || (texts = [])).push(prependNode);
break;
case BundleFileSectionKind.Internal:
if (stripInternal) break;
if (stripInternal) {
if (!texts) texts = [];
break;
}
// falls through
case BundleFileSectionKind.Text:
+4 -1
View File
@@ -228,7 +228,7 @@ interface Symbol {
if (section.kind !== BundleFileSectionKind.Prepend) {
writeTextOfSection(section.pos, section.end);
}
else {
else if (section.texts.length > 0) {
Debug.assert(section.pos === first(section.texts).pos);
Debug.assert(section.end === last(section.texts).end);
for (const text of section.texts) {
@@ -237,6 +237,9 @@ interface Symbol {
writeTextOfSection(text.pos, text.end);
}
}
else {
Debug.assert(section.pos === section.end);
}
}
baselineRecorder.WriteLine("======================================================================");
@@ -682,6 +682,40 @@ ${internal} enum internalEnum { a, b, c }`);
ignoreDtsUnchanged: true,
baselineOnly: true
});
verifyOutFileScenario({
subScenario: "stripInternal when prepend is completely internal",
baselineOnly: true,
ignoreDtsChanged: true,
ignoreDtsUnchanged: true,
modifyFs: fs => {
fs.writeFileSync(sources[project.first][source.ts][part.one], "/* @internal */ const A = 1;");
fs.writeFileSync(sources[project.third][source.ts][part.one], "const B = 2;");
fs.writeFileSync(sources[project.first][source.config], JSON.stringify({
compilerOptions: {
composite: true,
declaration: true,
declarationMap: true,
skipDefaultLibCheck: true,
sourceMap: true,
outFile: "./bin/first-output.js"
},
files: [sources[project.first][source.ts][part.one]]
}));
fs.writeFileSync(sources[project.third][source.config], JSON.stringify({
compilerOptions: {
composite: true,
declaration: true,
declarationMap: false,
stripInternal: true,
sourceMap: true,
outFile: "./thirdjs/output/third-output.js"
},
references: [{ path: "../first", prepend: true }],
files: [sources[project.third][source.ts][part.one]]
}));
}
});
});
describe("empty source files", () => {