committed by
GitHub
parent
20d2b4f98d
commit
e4f3964f67
20
node_modules/@babel/helper-split-export-declaration/lib/index.js
generated
vendored
20
node_modules/@babel/helper-split-export-declaration/lib/index.js
generated
vendored
@@ -17,16 +17,13 @@ const {
|
||||
} = _t;
|
||||
|
||||
function splitExportDeclaration(exportDeclaration) {
|
||||
if (!exportDeclaration.isExportDeclaration()) {
|
||||
throw new Error("Only export declarations can be split.");
|
||||
if (!exportDeclaration.isExportDeclaration() || exportDeclaration.isExportAllDeclaration()) {
|
||||
throw new Error("Only default and named export declarations can be split.");
|
||||
}
|
||||
|
||||
const isDefault = exportDeclaration.isExportDefaultDeclaration();
|
||||
const declaration = exportDeclaration.get("declaration");
|
||||
const isClassDeclaration = declaration.isClassDeclaration();
|
||||
|
||||
if (isDefault) {
|
||||
const standaloneDeclaration = declaration.isFunctionDeclaration() || isClassDeclaration;
|
||||
if (exportDeclaration.isExportDefaultDeclaration()) {
|
||||
const declaration = exportDeclaration.get("declaration");
|
||||
const standaloneDeclaration = declaration.isFunctionDeclaration() || declaration.isClassDeclaration();
|
||||
const scope = declaration.isScope() ? declaration.scope.parent : declaration.scope;
|
||||
let id = declaration.node.id;
|
||||
let needBindingRegistration = false;
|
||||
@@ -40,7 +37,7 @@ function splitExportDeclaration(exportDeclaration) {
|
||||
}
|
||||
}
|
||||
|
||||
const updatedDeclaration = standaloneDeclaration ? declaration : variableDeclaration("var", [variableDeclarator(cloneNode(id), declaration.node)]);
|
||||
const updatedDeclaration = standaloneDeclaration ? declaration.node : variableDeclaration("var", [variableDeclarator(cloneNode(id), declaration.node)]);
|
||||
const updatedExportDeclaration = exportNamedDeclaration(null, [exportSpecifier(cloneNode(id), identifier("default"))]);
|
||||
exportDeclaration.insertAfter(updatedExportDeclaration);
|
||||
exportDeclaration.replaceWith(updatedDeclaration);
|
||||
@@ -50,12 +47,11 @@ function splitExportDeclaration(exportDeclaration) {
|
||||
}
|
||||
|
||||
return exportDeclaration;
|
||||
}
|
||||
|
||||
if (exportDeclaration.get("specifiers").length > 0) {
|
||||
} else if (exportDeclaration.get("specifiers").length > 0) {
|
||||
throw new Error("It doesn't make sense to split exported specifiers.");
|
||||
}
|
||||
|
||||
const declaration = exportDeclaration.get("declaration");
|
||||
const bindingIdentifiers = declaration.getOuterBindingIdentifiers();
|
||||
const specifiers = Object.keys(bindingIdentifiers).map(name => {
|
||||
return exportSpecifier(identifier(name), identifier(name));
|
||||
|
7
node_modules/@babel/helper-split-export-declaration/package.json
generated
vendored
7
node_modules/@babel/helper-split-export-declaration/package.json
generated
vendored
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@babel/helper-split-export-declaration",
|
||||
"version": "7.16.7",
|
||||
"version": "7.18.6",
|
||||
"description": "",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -14,10 +14,11 @@
|
||||
},
|
||||
"main": "./lib/index.js",
|
||||
"dependencies": {
|
||||
"@babel/types": "^7.16.7"
|
||||
"@babel/types": "^7.18.6"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6.9.0"
|
||||
},
|
||||
"author": "The Babel Team (https://babel.dev/team)"
|
||||
"author": "The Babel Team (https://babel.dev/team)",
|
||||
"type": "commonjs"
|
||||
}
|
Reference in New Issue
Block a user