function replaceMatchingSpecifiers()

in packages/babel-plugin-named-asset-import/index.js [16:34]


  function replaceMatchingSpecifiers(path, loaderMap, callback) {
    const sourcePath = path.node.source.value;
    const ext = extname(sourcePath).substr(1);

    if (visited.has(path.node) || sourcePath.indexOf('!') !== -1) {
      return;
    }

    if (loaderMap[ext]) {
      path.replaceWithMultiple(
        path.node.specifiers.map(specifier => {
          const newSpecifier = callback(specifier, sourcePath);
          visited.add(newSpecifier);

          return newSpecifier;
        })
      );
    }
  }