@babel/helper-module-imports

    1. import { addSideEffect } from "@babel/helper-module-imports";

    import { named as _named } from "source"

    1. import { addNamed } from "@babel/helper-module-imports";

    import _default from "source"

    1. import { addDefault } from "@babel/helper-module-imports";
    2. addDefault(path, 'source', { nameHint: "hintedName" })

    import * as _namespace from "source"

    Examples

    1. import { addNamed } from "@babel/helper-module-imports";
    2. export default function({ types: t }) {
    3. return {
    4. visitor: {
    5. ReferencedIdentifier(path) {
    6. if (importName) {
    7. importName = t.cloneDeep(importName);
    8. } else {
    9. // require('bluebird').coroutine
    10. importName = this.importName = addNamed(path, 'coroutine', 'bluebird');
    11. }
    12. path.replaceWith(importName);
    13. }
    14. },