UNPKG

babel-plugin-remove-node-prefix

Version:
16 lines (15 loc) 873 B
function babelPluginRemoveNodePrefix(babel) { var t = babel.types; return { name: "remove-node-prefix", visitor: { StringLiteral: function(path) { var isImportOrRequire = t.isImportDeclaration(path.parent) || t.isExportAllDeclaration(path.parent) || t.isExportNamedDeclaration(path.parent) || t.isCallExpression(path.parent) && (t.isIdentifier(path.parent.callee) && ("require" === path.parent.callee.name || "import" === path.parent.callee.name) || t.isImport(path.parent.callee)); if (isImportOrRequire && path.node.value.startsWith("node:")) path.replaceWith(babel.types.stringLiteral(path.node.value.slice(5))); } } }; } var src_rslib_entry_ = babelPluginRemoveNodePrefix; export { babelPluginRemoveNodePrefix, src_rslib_entry_ as default }; //# sourceMappingURL=index.mjs.map