MCPcopy Index your code
hub / github.com/nodejs/node / transformAsynchronousModuleBody

Function transformAsynchronousModuleBody

test/fixtures/snapshot/typescript.js:104632–104658  ·  view source on GitHub ↗

* Transforms a SourceFile into an AMD or UMD module body. * * @param node The SourceFile node.

(node)

Source from the content-addressed store, hash-verified

104630 * @param node The SourceFile node.
104631 */
104632 function transformAsynchronousModuleBody(node) {
104633 startLexicalEnvironment();
104634 var statements = [];
104635 var statementOffset = factory.copyPrologue(node.statements, statements, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict, topLevelVisitor);
104636 if (shouldEmitUnderscoreUnderscoreESModule()) {
104637 ts.append(statements, createUnderscoreUnderscoreESModule());
104638 }
104639 if (ts.length(currentModuleInfo.exportedNames)) {
104640 ts.append(statements, factory.createExpressionStatement(ts.reduceLeft(currentModuleInfo.exportedNames, function (prev, nextId) { return factory.createAssignment(factory.createPropertyAccessExpression(factory.createIdentifier("exports"), factory.createIdentifier(ts.idText(nextId))), prev); }, factory.createVoidZero())));
104641 }
104642 // Visit each statement of the module body.
104643 ts.append(statements, ts.visitNode(currentModuleInfo.externalHelpersImportDeclaration, topLevelVisitor, ts.isStatement));
104644 if (moduleKind === ts.ModuleKind.AMD) {
104645 ts.addRange(statements, ts.mapDefined(currentModuleInfo.externalImports, getAMDImportExpressionForImport));
104646 }
104647 ts.addRange(statements, ts.visitNodes(node.statements, topLevelVisitor, ts.isStatement, statementOffset));
104648 // Append the 'export =' statement if provided.
104649 addExportEqualsIfNeeded(statements, /*emitAsReturn*/ true);
104650 // End the lexical environment for the module body
104651 // and merge any new lexical declarations.
104652 ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment());
104653 var body = factory.createBlock(statements, /*multiLine*/ true);
104654 if (needUMDDynamicImportHelper) {
104655 ts.addEmitHelper(body, dynamicImportUMDHelper);
104656 }
104657 return body;
104658 }
104659 /**
104660 * Adds the down-level representation of `export=` to the statement list if one exists
104661 * in the source file.

Callers 2

transformAMDModuleFunction · 0.85
transformUMDModuleFunction · 0.85

Calls 8

startLexicalEnvironmentFunction · 0.85
addExportEqualsIfNeededFunction · 0.85
endLexicalEnvironmentFunction · 0.85
addRangeMethod · 0.80
appendMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…