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

Function transformModule

test/fixtures/snapshot/typescript.js:104345–105814  ·  view source on GitHub ↗
(context)

Source from the content-addressed store, hash-verified

104343var ts;
104344(function (ts) {
104345 function transformModule(context) {
104346 function getTransformModuleDelegate(moduleKind) {
104347 switch (moduleKind) {
104348 case ts.ModuleKind.AMD: return transformAMDModule;
104349 case ts.ModuleKind.UMD: return transformUMDModule;
104350 default: return transformCommonJSModule;
104351 }
104352 }
104353 var factory = context.factory, emitHelpers = context.getEmitHelperFactory, startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration;
104354 var compilerOptions = context.getCompilerOptions();
104355 var resolver = context.getEmitResolver();
104356 var host = context.getEmitHost();
104357 var languageVersion = ts.getEmitScriptTarget(compilerOptions);
104358 var moduleKind = ts.getEmitModuleKind(compilerOptions);
104359 var previousOnSubstituteNode = context.onSubstituteNode;
104360 var previousOnEmitNode = context.onEmitNode;
104361 context.onSubstituteNode = onSubstituteNode;
104362 context.onEmitNode = onEmitNode;
104363 context.enableSubstitution(208 /* SyntaxKind.CallExpression */); // Substitute calls to imported/exported symbols to avoid incorrect `this`.
104364 context.enableSubstitution(210 /* SyntaxKind.TaggedTemplateExpression */); // Substitute calls to imported/exported symbols to avoid incorrect `this`.
104365 context.enableSubstitution(79 /* SyntaxKind.Identifier */); // Substitutes expression identifiers with imported/exported symbols.
104366 context.enableSubstitution(221 /* SyntaxKind.BinaryExpression */); // Substitutes assignments to exported symbols.
104367 context.enableSubstitution(297 /* SyntaxKind.ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols.
104368 context.enableEmitNotification(305 /* SyntaxKind.SourceFile */); // Restore state when substituting nodes in a file.
104369 var moduleInfoMap = []; // The ExternalModuleInfo for each file.
104370 var deferredExports = []; // Exports to defer until an EndOfDeclarationMarker is found.
104371 var currentSourceFile; // The current file.
104372 var currentModuleInfo; // The ExternalModuleInfo for the current file.
104373 var noSubstitution = []; // Set of nodes for which substitution rules should be ignored.
104374 var needUMDDynamicImportHelper;
104375 return ts.chainBundle(context, transformSourceFile);
104376 /**
104377 * Transforms the module aspects of a SourceFile.
104378 *
104379 * @param node The SourceFile node.
104380 */
104381 function transformSourceFile(node) {
104382 if (node.isDeclarationFile ||
104383 !(ts.isEffectiveExternalModule(node, compilerOptions) ||
104384 node.transformFlags & 4194304 /* TransformFlags.ContainsDynamicImport */ ||
104385 (ts.isJsonSourceFile(node) && ts.hasJsonModuleEmitEnabled(compilerOptions) && ts.outFile(compilerOptions)))) {
104386 return node;
104387 }
104388 currentSourceFile = node;
104389 currentModuleInfo = ts.collectExternalModuleInfo(context, node, resolver, compilerOptions);
104390 moduleInfoMap[ts.getOriginalNodeId(node)] = currentModuleInfo;
104391 // Perform the transformation.
104392 var transformModule = getTransformModuleDelegate(moduleKind);
104393 var updated = transformModule(node);
104394 currentSourceFile = undefined;
104395 currentModuleInfo = undefined;
104396 needUMDDynamicImportHelper = false;
104397 return updated;
104398 }
104399 function shouldEmitUnderscoreUnderscoreESModule() {
104400 if (!currentModuleInfo.exportEquals && ts.isExternalModule(currentSourceFile)) {
104401 return true;
104402 }

Callers 1

transformSourceFileFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected