Added babel-helper-split-export-declaration (#7313)
This commit is contained in:
committed by
GitHub
parent
ea3f2d9299
commit
4d164bd8e6
@@ -11,6 +11,7 @@
|
||||
"@babel/helper-function-name": "7.0.0-beta.40",
|
||||
"@babel/helper-optimise-call-expression": "7.0.0-beta.40",
|
||||
"@babel/helper-replace-supers": "7.0.0-beta.40",
|
||||
"@babel/helper-split-export-declaration": "7.0.0-beta.40",
|
||||
"globals": "^11.1.0"
|
||||
},
|
||||
"keywords": [
|
||||
|
||||
@@ -2,6 +2,7 @@ import LooseTransformer from "./loose";
|
||||
import VanillaTransformer from "./vanilla";
|
||||
import annotateAsPure from "@babel/helper-annotate-as-pure";
|
||||
import nameFunction from "@babel/helper-function-name";
|
||||
import splitExportDeclaration from "@babel/helper-split-export-declaration";
|
||||
import { types as t } from "@babel/core";
|
||||
import globals from "globals";
|
||||
|
||||
@@ -24,19 +25,7 @@ export default function(api, options) {
|
||||
visitor: {
|
||||
ExportDefaultDeclaration(path) {
|
||||
if (!path.get("declaration").isClassDeclaration()) return;
|
||||
|
||||
const { node } = path;
|
||||
const ref =
|
||||
node.declaration.id || path.scope.generateUidIdentifier("class");
|
||||
node.declaration.id = ref;
|
||||
|
||||
// Split the class declaration and the export into two separate statements.
|
||||
path.replaceWith(node.declaration);
|
||||
path.insertAfter(
|
||||
t.exportNamedDeclaration(null, [
|
||||
t.exportSpecifier(t.cloneNode(ref), t.identifier("default")),
|
||||
]),
|
||||
);
|
||||
splitExportDeclaration(path);
|
||||
},
|
||||
|
||||
ClassDeclaration(path) {
|
||||
|
||||
@@ -5,8 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
var _class = function _class() {
|
||||
babelHelpers.classCallCheck(this, _class);
|
||||
var _default = function _default() {
|
||||
babelHelpers.classCallCheck(this, _default);
|
||||
};
|
||||
|
||||
exports.default = _class;
|
||||
exports.default = _default;
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
var _class =
|
||||
var _default =
|
||||
/*#__PURE__*/
|
||||
function (_A) {
|
||||
babelHelpers.inherits(_class, _A);
|
||||
babelHelpers.inherits(_default, _A);
|
||||
|
||||
function _class() {
|
||||
babelHelpers.classCallCheck(this, _class);
|
||||
return babelHelpers.possibleConstructorReturn(this, (_class.__proto__ || Object.getPrototypeOf(_class)).apply(this, arguments));
|
||||
function _default() {
|
||||
babelHelpers.classCallCheck(this, _default);
|
||||
return babelHelpers.possibleConstructorReturn(this, (_default.__proto__ || Object.getPrototypeOf(_default)).apply(this, arguments));
|
||||
}
|
||||
|
||||
return _class;
|
||||
return _default;
|
||||
}(A);
|
||||
|
||||
export { _class as default };
|
||||
export { _default as default };
|
||||
|
||||
Reference in New Issue
Block a user