New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

babel-plugin-transform-es2015-modules-commonjs

Package Overview
Dependencies
Maintainers
5
Versions
59
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-transform-es2015-modules-commonjs - npm Package Compare versions

Comparing version 7.0.0-alpha.18 to 7.0.0-alpha.19

139

lib/index.js

@@ -23,3 +23,3 @@ "use strict";

} else {
path.replaceWith(remap);
path.replaceWith(t.cloneWithoutLoc(remap));
}

@@ -53,4 +53,4 @@

var _reid = _ref;
node = buildExportsAssignment(_reid, node).expression;
var reid = _ref;
node = buildExportsAssignment(reid, node).expression;
}

@@ -73,8 +73,8 @@

var _property = _ref2;
var _name2 = _property.value.name;
var _exports2 = this.exports[_name2];
if (!_exports2) continue;
var property = _ref2;
var _name = property.value.name;
var _exports = this.exports[_name];
if (!_exports) continue;
if (this.scope.getBinding(_name2) !== path.scope.getBinding(_name2)) {
if (this.scope.getBinding(_name) !== path.scope.getBinding(_name)) {
return;

@@ -84,3 +84,3 @@ }

node[REASSIGN_REMAP_SKIP] = true;
path.insertAfter(buildExportsAssignment(t.identifier(_name2), t.identifier(_name2)));
path.insertAfter(buildExportsAssignment(t.identifier(_name), t.identifier(_name)));
}

@@ -100,8 +100,9 @@ } else if (left.isArrayPattern()) {

var _element = _ref3;
var _name4 = _element.name;
var _exports4 = this.exports[_name4];
if (!_exports4) continue;
var element = _ref3;
if (!element) continue;
var _name2 = element.name;
var _exports2 = this.exports[_name2];
if (!_exports2) continue;
if (this.scope.getBinding(_name4) !== path.scope.getBinding(_name4)) {
if (this.scope.getBinding(_name2) !== path.scope.getBinding(_name2)) {
return;

@@ -111,3 +112,3 @@ }

node[REASSIGN_REMAP_SKIP] = true;
path.insertAfter(buildExportsAssignment(t.identifier(_name4), t.identifier(_name4)));
path.insertAfter(buildExportsAssignment(t.identifier(_name2), t.identifier(_name2)));
}

@@ -179,3 +180,3 @@ }

if (cached) return cached;
var ref = path.scope.generateUidIdentifier((0, _path3.basename)(source, (0, _path3.extname)(source)));
var ref = path.scope.generateUidIdentifier((0, _path2.basename)(source, (0, _path2.extname)(source)));
var varDecl = t.variableDeclaration("var", [t.variableDeclarator(ref, buildRequire(t.stringLiteral(source)).expression)]);

@@ -212,8 +213,8 @@

var _path2 = _ref4;
var _path = _ref4;
if (_path2.isExportDeclaration()) {
if (_path.isExportDeclaration()) {
hasExports = true;
var _specifiers = [].concat(_path2.get("declaration"), _path2.get("specifiers"));
var _specifiers = [].concat(_path.get("declaration"), _path.get("specifiers"));

@@ -232,8 +233,8 @@ for (var _iterator6 = _specifiers, _isArray6 = Array.isArray(_iterator6), _i6 = 0, _iterator6 = _isArray6 ? _iterator6 : _iterator6[Symbol.iterator]();;) {

var _specifier4 = _ref6;
var _specifier2 = _ref6;
var ids = _specifier4.getBindingIdentifiers();
var ids = _specifier2.getBindingIdentifiers();
if (ids.__esModule) {
throw _specifier4.buildCodeFrameError('Illegal export "__esModule"');
throw _specifier2.buildCodeFrameError('Illegal export "__esModule"');
}

@@ -243,17 +244,17 @@ }

if (_path2.isImportDeclaration()) {
if (_path.isImportDeclaration()) {
var _importsEntry$specifi;
hasImports = true;
var key = _path2.node.source.value;
var key = _path.node.source.value;
var importsEntry = imports[key] || {
specifiers: [],
maxBlockHoist: 0,
loc: _path2.node.loc
loc: _path.node.loc
};
(_importsEntry$specifi = importsEntry.specifiers).push.apply(_importsEntry$specifi, _path2.node.specifiers);
(_importsEntry$specifi = importsEntry.specifiers).push.apply(_importsEntry$specifi, _path.node.specifiers);
if (typeof _path2.node._blockHoist === "number") {
importsEntry.maxBlockHoist = Math.max(_path2.node._blockHoist, importsEntry.maxBlockHoist);
if (typeof _path.node._blockHoist === "number") {
importsEntry.maxBlockHoist = Math.max(_path.node._blockHoist, importsEntry.maxBlockHoist);
}

@@ -263,5 +264,5 @@

_path2.remove();
} else if (_path2.isExportDefaultDeclaration()) {
var declaration = _path2.get("declaration");
_path.remove();
} else if (_path.isExportDefaultDeclaration()) {
var declaration = _path.get("declaration");

@@ -276,7 +277,7 @@ if (declaration.isFunctionDeclaration()) {

_path2.replaceWith(declaration.node);
_path.replaceWith(declaration.node);
} else {
topNodes.push(buildExportsAssignment(defNode, t.toExpression(declaration.node)));
_path2.remove();
_path.remove();
}

@@ -291,15 +292,15 @@ } else if (declaration.isClassDeclaration()) {

_path2.replaceWithMultiple([declaration.node, buildExportsAssignment(_defNode, _id)]);
_path.replaceWithMultiple([declaration.node, buildExportsAssignment(_defNode, _id)]);
} else {
_path2.replaceWith(buildExportsAssignment(_defNode, t.toExpression(declaration.node)));
_path.replaceWith(buildExportsAssignment(_defNode, t.toExpression(declaration.node)));
_path2.parentPath.requeue(_path2.get("expression.left"));
_path.parentPath.requeue(_path.get("expression.left"));
}
} else {
_path2.replaceWith(buildExportsAssignment(t.identifier("default"), declaration.node));
_path.replaceWith(buildExportsAssignment(t.identifier("default"), declaration.node));
_path2.parentPath.requeue(_path2.get("expression.left"));
_path.parentPath.requeue(_path.get("expression.left"));
}
} else if (_path2.isExportNamedDeclaration()) {
var _declaration = _path2.get("declaration");
} else if (_path.isExportNamedDeclaration()) {
var _declaration = _path.get("declaration");

@@ -312,3 +313,3 @@ if (_declaration.node) {

_path2.replaceWith(_declaration.node);
_path.replaceWith(_declaration.node);
} else if (_declaration.isClassDeclaration()) {

@@ -318,3 +319,3 @@ var _id3 = _declaration.node.id;

_path2.replaceWithMultiple([_declaration.node, buildExportsAssignment(_id3, _id3)]);
_path.replaceWithMultiple([_declaration.node, buildExportsAssignment(_id3, _id3)]);

@@ -336,3 +337,3 @@ nonHoistedExportNames[_id3.name] = true;

var init = parentPath.get("init");
var assignment = buildExportsAssignment(node, init.node || _path2.scope.buildUndefinedNode());
var assignment = buildExportsAssignment(node, init.node || _path.scope.buildUndefinedNode());
init.replaceWith(assignment.expression);

@@ -344,5 +345,5 @@ } else {

_path2.insertAfter(exportsToInsert);
_path.insertAfter(exportsToInsert);
_path2.replaceWith(_declaration.node);
_path.replaceWith(_declaration.node);
}

@@ -353,9 +354,9 @@

var _specifiers2 = _path2.get("specifiers");
var _specifiers2 = _path.get("specifiers");
var nodes = [];
var _source = _path2.node.source;
var _source = _path.node.source;
if (_source) {
var ref = addRequire(_source.value, _path2.node._blockHoist);
var ref = addRequire(_source.value, _path.node._blockHoist);

@@ -374,12 +375,12 @@ for (var _iterator7 = _specifiers2, _isArray7 = Array.isArray(_iterator7), _i7 = 0, _iterator7 = _isArray7 ? _iterator7 : _iterator7[Symbol.iterator]();;) {

var _specifier6 = _ref7;
var _specifier3 = _ref7;
if (_specifier6.isExportNamespaceSpecifier()) {} else if (_specifier6.isExportDefaultSpecifier()) {} else if (_specifier6.isExportSpecifier()) {
if (!noInterop && _specifier6.node.local.name === "default") {
topNodes.push(buildExportsFrom(t.stringLiteral(_specifier6.node.exported.name), t.memberExpression(t.callExpression(this.addHelper("interopRequireDefault"), [ref]), _specifier6.node.local)));
if (_specifier3.isExportNamespaceSpecifier()) {} else if (_specifier3.isExportDefaultSpecifier()) {} else if (_specifier3.isExportSpecifier()) {
if (!noInterop && _specifier3.node.local.name === "default") {
topNodes.push(buildExportsFrom(t.stringLiteral(_specifier3.node.exported.name), t.memberExpression(t.callExpression(this.addHelper("interopRequireDefault"), [ref]), _specifier3.node.local)));
} else {
topNodes.push(buildExportsFrom(t.stringLiteral(_specifier6.node.exported.name), t.memberExpression(ref, _specifier6.node.local)));
topNodes.push(buildExportsFrom(t.stringLiteral(_specifier3.node.exported.name), t.memberExpression(ref, _specifier3.node.local)));
}
nonHoistedExportNames[_specifier6.node.exported.name] = true;
nonHoistedExportNames[_specifier3.node.exported.name] = true;
}

@@ -400,8 +401,8 @@ }

var _specifier8 = _ref8;
var _specifier4 = _ref8;
if (_specifier8.isExportSpecifier()) {
addTo(exports, _specifier8.node.local.name, _specifier8.node.exported);
nonHoistedExportNames[_specifier8.node.exported.name] = true;
nodes.push(buildExportsAssignment(_specifier8.node.exported, _specifier8.node.local));
if (_specifier4.isExportSpecifier()) {
addTo(exports, _specifier4.node.local.name, _specifier4.node.exported);
nonHoistedExportNames[_specifier4.node.exported.name] = true;
nodes.push(buildExportsAssignment(_specifier4.node.exported, _specifier4.node.local));
}

@@ -411,11 +412,11 @@ }

_path2.replaceWithMultiple(nodes);
} else if (_path2.isExportAllDeclaration()) {
_path.replaceWithMultiple(nodes);
} else if (_path.isExportAllDeclaration()) {
var exportNode = buildExportAll({
OBJECT: addRequire(_path2.node.source.value, _path2.node._blockHoist)
OBJECT: addRequire(_path.node.source.value, _path.node._blockHoist)
});
exportNode.loc = _path2.node.loc;
exportNode.loc = _path.node.loc;
topNodes.push(exportNode);
_path2.remove();
_path.remove();
}

@@ -467,8 +468,8 @@ }

var _specifier2 = _ref5;
var _specifier = _ref5;
if (t.isImportSpecifier(_specifier2)) {
if (t.isImportSpecifier(_specifier)) {
var target = uid;
if (_specifier2.imported.name === "default") {
if (_specifier.imported.name === "default") {
if (wildcard) {

@@ -489,3 +490,3 @@ target = wildcard;

remaps[_specifier2.local.name] = t.memberExpression(target, t.cloneWithoutLoc(_specifier2.imported));
remaps[_specifier.local.name] = t.memberExpression(target, t.cloneWithoutLoc(_specifier.imported));
}

@@ -547,3 +548,3 @@ }

var _path3 = require("path");
var _path2 = require("path");

@@ -550,0 +551,0 @@ var _babelTemplate = require("babel-template");

{
"name": "babel-plugin-transform-es2015-modules-commonjs",
"version": "7.0.0-alpha.18",
"version": "7.0.0-alpha.19",
"description": "This plugin transforms ES2015 modules to CommonJS",

@@ -9,5 +9,5 @@ "repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-es2015-modules-commonjs",

"dependencies": {
"babel-plugin-transform-strict-mode": "7.0.0-alpha.18",
"babel-template": "7.0.0-alpha.18",
"babel-types": "7.0.0-alpha.18"
"babel-plugin-transform-strict-mode": "7.0.0-alpha.19",
"babel-template": "7.0.0-alpha.19",
"babel-types": "7.0.0-alpha.19"
},

@@ -18,5 +18,5 @@ "keywords": [

"devDependencies": {
"babel-helper-plugin-test-runner": "7.0.0-alpha.18",
"babel-plugin-syntax-object-rest-spread": "7.0.0-alpha.18"
"babel-helper-plugin-test-runner": "7.0.0-alpha.19",
"babel-plugin-syntax-object-rest-spread": "7.0.0-alpha.19"
}
}
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