This commit is contained in:
Yamozha
2021-04-02 02:24:13 +03:00
parent c23950b545
commit 7256d79e2c
31493 changed files with 3036630 additions and 0 deletions

View File

@ -0,0 +1,50 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _helperPluginUtils = require("@babel/helper-plugin-utils");
var _pluginSyntaxExportDefaultFrom = _interopRequireDefault(require("@babel/plugin-syntax-export-default-from"));
var _core = require("@babel/core");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _default = (0, _helperPluginUtils.declare)(api => {
api.assertVersion(7);
return {
name: "proposal-export-default-from",
inherits: _pluginSyntaxExportDefaultFrom.default,
visitor: {
ExportNamedDeclaration(path) {
const {
node,
scope
} = path;
const {
specifiers
} = node;
if (!_core.types.isExportDefaultSpecifier(specifiers[0])) return;
const specifier = specifiers.shift();
const {
exported
} = specifier;
const uid = scope.generateUidIdentifier(exported.name);
const nodes = [_core.types.importDeclaration([_core.types.importDefaultSpecifier(uid)], _core.types.cloneNode(node.source)), _core.types.exportNamedDeclaration(null, [_core.types.exportSpecifier(_core.types.cloneNode(uid), exported)])];
if (specifiers.length >= 1) {
nodes.push(node);
}
const [importDeclaration] = path.replaceWithMultiple(nodes);
path.scope.registerDeclaration(importDeclaration);
}
}
};
});
exports.default = _default;