mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-14 19:16:17 -06:00
Give a better name for the boolean variable; emit __esmodule for export import
This commit is contained in:
parent
4331de3338
commit
c0ac84fdbd
@ -45,7 +45,7 @@ namespace ts {
|
||||
let currentSourceFile: SourceFile; // The current file.
|
||||
let currentModuleInfo: ExternalModuleInfo; // The ExternalModuleInfo for the current file.
|
||||
let noSubstitution: boolean[]; // Set of nodes for which substitution rules should be ignored.
|
||||
let shouldAppendUnderscoreUnderscoreEsModule: boolean; // A boolean indicating whether "__esModule" should be emitted
|
||||
let shouldAppendEsModuleMarker: boolean; // A boolean indicating whether "__esModule" should be emitted
|
||||
|
||||
return transformSourceFile;
|
||||
|
||||
@ -63,7 +63,7 @@ namespace ts {
|
||||
|
||||
currentSourceFile = node;
|
||||
currentModuleInfo = collectExternalModuleInfo(node, resolver, compilerOptions);
|
||||
shouldAppendUnderscoreUnderscoreEsModule = false;
|
||||
shouldAppendEsModuleMarker = false;
|
||||
moduleInfoMap[getOriginalNodeId(node)] = currentModuleInfo;
|
||||
|
||||
// Perform the transformation.
|
||||
@ -90,7 +90,7 @@ namespace ts {
|
||||
addRange(statements, endLexicalEnvironment());
|
||||
addExportEqualsIfNeeded(statements, /*emitAsReturn*/ false);
|
||||
|
||||
if (shouldAppendUnderscoreUnderscoreEsModule) {
|
||||
if (shouldAppendEsModuleMarker) {
|
||||
append(statements, createUnderscoreUnderscoreESModule());
|
||||
}
|
||||
|
||||
@ -383,7 +383,7 @@ namespace ts {
|
||||
// Append the 'export =' statement if provided.
|
||||
addExportEqualsIfNeeded(statements, /*emitAsReturn*/ true);
|
||||
|
||||
if (shouldAppendUnderscoreUnderscoreEsModule) {
|
||||
if (shouldAppendEsModuleMarker) {
|
||||
append(statements, createUnderscoreUnderscoreESModule());
|
||||
}
|
||||
|
||||
@ -666,7 +666,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
const generatedName = getGeneratedNameForNode(node);
|
||||
shouldAppendUnderscoreUnderscoreEsModule = true;
|
||||
shouldAppendEsModuleMarker = true;
|
||||
|
||||
if (node.exportClause) {
|
||||
const statements: Statement[] = [];
|
||||
@ -833,9 +833,10 @@ namespace ts {
|
||||
let expressions: Expression[];
|
||||
|
||||
const parseTreeNode = getParseTreeNode(node);
|
||||
if (!shouldAppendUnderscoreUnderscoreEsModule) {
|
||||
if (parseTreeNode && !shouldAppendEsModuleMarker) {
|
||||
// class declaration get down-level transformed to be variable statement
|
||||
shouldAppendUnderscoreUnderscoreEsModule = (parseTreeNode.kind === SyntaxKind.VariableStatement || parseTreeNode.kind === SyntaxKind.ClassDeclaration) && hasModifier(parseTreeNode, ModifierFlags.Export);
|
||||
shouldAppendEsModuleMarker = (parseTreeNode.kind === SyntaxKind.VariableStatement || parseTreeNode.kind === SyntaxKind.ClassDeclaration || parseTreeNode.kind === SyntaxKind.ImportEqualsDeclaration)
|
||||
&& hasModifier(parseTreeNode, ModifierFlags.Export);
|
||||
}
|
||||
|
||||
if (hasModifier(node, ModifierFlags.Export)) {
|
||||
@ -1125,7 +1126,7 @@ namespace ts {
|
||||
* @param allowComments Whether to allow comments on the export.
|
||||
*/
|
||||
function appendExportStatement(statements: Statement[] | undefined, exportName: Identifier, expression: Expression, location?: TextRange, allowComments?: boolean): Statement[] | undefined {
|
||||
shouldAppendUnderscoreUnderscoreEsModule = true;
|
||||
shouldAppendEsModuleMarker = true;
|
||||
statements = append(statements, createExportStatement(exportName, expression, location, allowComments));
|
||||
return statements;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user