Rename all proposal plugins to -proposal- from -transform- (#6570)
This commit is contained in:
30
packages/babel-plugin-proposal-export-default/src/index.js
Normal file
30
packages/babel-plugin-proposal-export-default/src/index.js
Normal file
@@ -0,0 +1,30 @@
|
||||
import syntaxExportExtensions from "@babel/plugin-syntax-export-extensions";
|
||||
|
||||
export default function({ types: t }) {
|
||||
return {
|
||||
inherits: syntaxExportExtensions,
|
||||
|
||||
visitor: {
|
||||
ExportNamedDeclaration(path) {
|
||||
const { node, scope } = path;
|
||||
const { specifiers } = node;
|
||||
if (!t.isExportDefaultSpecifier(specifiers[0])) return;
|
||||
|
||||
const specifier = specifiers.shift();
|
||||
const { exported } = specifier;
|
||||
const uid = scope.generateUidIdentifier(exported.name);
|
||||
|
||||
const nodes = [
|
||||
t.importDeclaration([t.importDefaultSpecifier(uid)], node.source),
|
||||
t.exportNamedDeclaration(null, [t.exportSpecifier(uid, exported)]),
|
||||
];
|
||||
|
||||
if (specifiers.length >= 1) {
|
||||
nodes.push(node);
|
||||
}
|
||||
|
||||
path.replaceWithMultiple(nodes);
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user