MCPcopy Create free account
hub / github.com/nodejs/node / collectAsynchronousDependencies

Function collectAsynchronousDependencies

test/fixtures/snapshot/typescript.js:104572–104615  ·  view source on GitHub ↗

* Collect the additional asynchronous dependencies for the module. * * @param node The source file. * @param includeNonAmdDependencies A value indicating whether to include non-AMD dependencies.

(node, includeNonAmdDependencies)

Source from the content-addressed store, hash-verified

104570 * @param includeNonAmdDependencies A value indicating whether to include non-AMD dependencies.
104571 */
104572 function collectAsynchronousDependencies(node, includeNonAmdDependencies) {
104573 // names of modules with corresponding parameter in the factory function
104574 var aliasedModuleNames = [];
104575 // names of modules with no corresponding parameters in factory function
104576 var unaliasedModuleNames = [];
104577 // names of the parameters in the factory function; these
104578 // parameters need to match the indexes of the corresponding
104579 // module names in aliasedModuleNames.
104580 var importAliasNames = [];
104581 // Fill in amd-dependency tags
104582 for (var _i = 0, _a = node.amdDependencies; _i < _a.length; _i++) {
104583 var amdDependency = _a[_i];
104584 if (amdDependency.name) {
104585 aliasedModuleNames.push(factory.createStringLiteral(amdDependency.path));
104586 importAliasNames.push(factory.createParameterDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, amdDependency.name));
104587 }
104588 else {
104589 unaliasedModuleNames.push(factory.createStringLiteral(amdDependency.path));
104590 }
104591 }
104592 for (var _b = 0, _c = currentModuleInfo.externalImports; _b < _c.length; _b++) {
104593 var importNode = _c[_b];
104594 // Find the name of the external module
104595 var externalModuleName = ts.getExternalModuleNameLiteral(factory, importNode, currentSourceFile, host, resolver, compilerOptions);
104596 // Find the name of the module alias, if there is one
104597 var importAliasName = ts.getLocalNameForExternalImport(factory, importNode, currentSourceFile);
104598 // It is possible that externalModuleName is undefined if it is not string literal.
104599 // This can happen in the invalid import syntax.
104600 // E.g : "import * from alias from 'someLib';"
104601 if (externalModuleName) {
104602 if (includeNonAmdDependencies && importAliasName) {
104603 // Set emitFlags on the name of the classDeclaration
104604 // This is so that when printer will not substitute the identifier
104605 ts.setEmitFlags(importAliasName, 4 /* EmitFlags.NoSubstitution */);
104606 aliasedModuleNames.push(externalModuleName);
104607 importAliasNames.push(factory.createParameterDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, importAliasName));
104608 }
104609 else {
104610 unaliasedModuleNames.push(externalModuleName);
104611 }
104612 }
104613 }
104614 return { aliasedModuleNames: aliasedModuleNames, unaliasedModuleNames: unaliasedModuleNames, importAliasNames: importAliasNames };
104615 }
104616 function getAMDImportExpressionForImport(node) {
104617 if (ts.isImportEqualsDeclaration(node) || ts.isExportDeclaration(node) || !ts.getExternalModuleNameLiteral(factory, node, currentSourceFile, host, resolver, compilerOptions)) {
104618 return undefined;

Callers 2

transformAMDModuleFunction · 0.85
transformUMDModuleFunction · 0.85

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected