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.19 to 7.0.0-alpha.20

142

lib/index.js

@@ -52,4 +52,4 @@ "use strict";

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

@@ -72,8 +72,8 @@

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

@@ -83,3 +83,3 @@ }

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

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

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

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

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

@@ -154,3 +154,3 @@ }

})) {
path.replaceWith(t.identifier("undefined"));
path.replaceWith(path.scope.buildUndefinedNode());
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

var _specifier3 = _ref7;
var _specifier6 = _ref7;
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)));
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)));
} else {
topNodes.push(buildExportsFrom(t.stringLiteral(_specifier3.node.exported.name), t.memberExpression(ref, _specifier3.node.local)));
topNodes.push(buildExportsFrom(t.stringLiteral(_specifier6.node.exported.name), t.memberExpression(ref, _specifier6.node.local)));
}
nonHoistedExportNames[_specifier3.node.exported.name] = true;
nonHoistedExportNames[_specifier6.node.exported.name] = true;
}

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

var _specifier4 = _ref8;
var _specifier8 = _ref8;
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));
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));
}

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

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

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

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

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

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

@@ -507,3 +507,3 @@ }

var nonHoistedExportNamesChunk = nonHoistedExportNamesArr.slice(currentExportsNodeAssignmentLength, currentExportsNodeAssignmentLength + maxHoistedExportsNodeAssignmentLength);
var hoistedExportsNode = t.identifier("undefined");
var hoistedExportsNode = scope.buildUndefinedNode();
nonHoistedExportNamesChunk.forEach(function (name) {

@@ -549,3 +549,3 @@ hoistedExportsNode = buildExportsAssignment(t.identifier(name), hoistedExportsNode).expression;

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

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

{
"name": "babel-plugin-transform-es2015-modules-commonjs",
"version": "7.0.0-alpha.19",
"version": "7.0.0-alpha.20",
"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.19",
"babel-template": "7.0.0-alpha.19",
"babel-types": "7.0.0-alpha.19"
"babel-plugin-transform-strict-mode": "7.0.0-alpha.20",
"babel-template": "7.0.0-alpha.20",
"babel-types": "7.0.0-alpha.20"
},

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

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