@babel/helper-module-imports
import { addSideEffect } from "@babel/helper-module-imports";
import { named as _named } from "source"
import { addNamed } from "@babel/helper-module-imports";
import _default from "source"
import { addDefault } from "@babel/helper-module-imports";
addDefault(path, 'source', { nameHint: "hintedName" })
import * as _namespace from "source"
Examples
import { addNamed } from "@babel/helper-module-imports";
export default function({ types: t }) {
return {
visitor: {
ReferencedIdentifier(path) {
if (importName) {
importName = t.cloneDeep(importName);
} else {
// require('bluebird').coroutine
importName = this.importName = addNamed(path, 'coroutine', 'bluebird');
}
path.replaceWith(importName);
}
},