ImportDeclaration()

in fusion-cli/build/babel-plugins/babel-plugin-utils/visit-named-module.js [35:64]


    ImportDeclaration(path /*: Object */, state /*: Object */) {
      const sourceName = path.get('source').node.value;
      if (
        (Array.isArray(packageName) &&
          packageName.indexOf(sourceName) === -1) ||
        (typeof packageName === 'string' && sourceName !== packageName)
      ) {
        return;
      }
      state.importedPackageName = sourceName;
      path.get('specifiers').forEach(specifier => {
        const localPath = specifier.get('local');
        const localName = localPath.node.name;
        if (!localPath.scope.bindings[localName]) {
          return;
        }
        const refPaths = localPath.scope.bindings[localName].referencePaths;
        if (t.isImportSpecifier(specifier)) {
          // import {moduleName} from 'packageName';
          const specifierName = specifier.get('imported').node.name;
          if (compareToModuleName(specifierName)) {
            // $FlowFixMe
            refsHandler(t, state, refPaths, specifierName, specifier);
          }
        } else if (t.isImportNamespaceSpecifier(specifier)) {
          // import * as pkg from 'packageName';
          // TODO(#5): Handle this case, or issue a warning because this may not be 100% robust
        }
      });
    },