babel-helper-references-import
v0.0.2
Published
Helper for rewriting imports from a particular library.
Downloads
2
Readme
babel-helper-references-import
Checks whether an Identifier
or MemberExpression
references a specific import from a specific package.
Like referencesImport
, but works with ES2015, CommonJS and AMD syntax.
API
This package contains a single named export:
referencesImport(path: NodePath, packageName: string, importName: string): boolean;
path
is a path to the node that you want to test whether it references an import from a package.packageName
is the name of the package.importName
is the name of the import. It can take a special value,*
, to indicate that you want to test that the whole namespace is imported, for example when testing thatfoo
referencesimport * as foo from 'package';
orconst foo = require('package');
TODO
- Dynamic imports
- Consider when errors should be thrown rather than just not matching.
- Make the build not fail. This relies on my PR being merged.