mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-13 22:00:59 -05:00
Fix prologue emitting in case of modules with --out scenario
This commit is contained in:
@@ -3377,7 +3377,7 @@ namespace ts {
|
||||
* Emits any prologue directives at the start of a Statement list, returning the
|
||||
* number of prologue directives written to the output.
|
||||
*/
|
||||
function emitPrologueDirectives(statements: ReadonlyArray<Node>, sourceFile?: SourceFile, seenPrologueDirectives?: Map<true>): number {
|
||||
function emitPrologueDirectives(statements: ReadonlyArray<Node>, sourceFile?: SourceFile, seenPrologueDirectives?: Map<true>, recordBundleFileSection?: true): number {
|
||||
let needsToSetSourceFile = !!sourceFile;
|
||||
for (let i = 0; i < statements.length; i++) {
|
||||
const statement = statements[i];
|
||||
@@ -3391,7 +3391,7 @@ namespace ts {
|
||||
writeLine();
|
||||
const pos = writer.getTextPos();
|
||||
emit(statement);
|
||||
if (bundleFileInfo) bundleFileInfo.sections.push({ pos, end: writer.getTextPos(), kind: BundleFileSectionKind.Prologue, data: statement.expression.text });
|
||||
if (recordBundleFileSection && bundleFileInfo) bundleFileInfo.sections.push({ pos, end: writer.getTextPos(), kind: BundleFileSectionKind.Prologue, data: statement.expression.text });
|
||||
if (seenPrologueDirectives) {
|
||||
seenPrologueDirectives.set(statement.expression.text, true);
|
||||
}
|
||||
@@ -3430,7 +3430,7 @@ namespace ts {
|
||||
emitUnparsedPrologues((prepend as UnparsedSource).prologues, seenPrologueDirectives);
|
||||
}
|
||||
for (const sourceFile of sourceFileOrBundle.sourceFiles) {
|
||||
emitPrologueDirectives(sourceFile.statements, sourceFile, seenPrologueDirectives);
|
||||
emitPrologueDirectives(sourceFile.statements, sourceFile, seenPrologueDirectives, /*recordBundleFileSection*/ true);
|
||||
}
|
||||
setSourceFile(undefined);
|
||||
}
|
||||
|
||||
@@ -109,6 +109,7 @@ namespace ts {
|
||||
enableStrict(fs, sources[project.lib][source.config]);
|
||||
addTestPrologue(fs, sources[project.lib][source.ts][0], `"myPrologue"`);
|
||||
addTestPrologue(fs, sources[project.lib][source.ts][2], `"myPrologueFile"`);
|
||||
addTestPrologue(fs, sources[project.lib][source.ts][3], `"myPrologue3"`);
|
||||
enableStrict(fs, sources[project.app][source.config]);
|
||||
addTestPrologue(fs, sources[project.app][source.ts][0], `"myPrologue"`);
|
||||
addTestPrologue(fs, sources[project.app][source.ts][1], `"myPrologue2";`);
|
||||
@@ -160,7 +161,7 @@ namespace ts {
|
||||
function stripInternalScenario(fs: vfs.FileSystem) {
|
||||
const internal = "/*@internal*/";
|
||||
replaceText(fs, sources[project.app][source.config], `"composite": true,`, `"composite": true,
|
||||
"stripInternal": true,`);;
|
||||
"stripInternal": true,`);
|
||||
replaceText(fs, sources[project.lib][source.ts][0], "const", `${internal} const`);
|
||||
appendText(fs, sources[project.lib][source.ts][1], `
|
||||
export class normalC {
|
||||
|
||||
Reference in New Issue
Block a user