Socket
Socket
Sign inDemoInstall

@babel/helper-split-export-declaration

Package Overview
Dependencies
Maintainers
4
Versions
60
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@babel/helper-split-export-declaration - npm Package Compare versions

Comparing version 7.16.7 to 7.18.6

20

lib/index.js

@@ -20,12 +20,9 @@ "use strict";

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;

@@ -44,3 +41,3 @@ let id = declaration.node.id;

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"))]);

@@ -55,8 +52,7 @@ exportDeclaration.insertAfter(updatedExportDeclaration);

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();

@@ -63,0 +59,0 @@ const specifiers = Object.keys(bindingIdentifiers).map(name => {

7

package.json
{
"name": "@babel/helper-split-export-declaration",
"version": "7.16.7",
"version": "7.18.6",
"description": "",

@@ -17,3 +17,3 @@ "repository": {

"dependencies": {
"@babel/types": "^7.16.7"
"@babel/types": "^7.18.6"
},

@@ -23,3 +23,4 @@ "engines": {

},
"author": "The Babel Team (https://babel.dev/team)"
"author": "The Babel Team (https://babel.dev/team)",
"type": "commonjs"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc