Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

babel-plugin-add-module-exports

Package Overview
Dependencies
Maintainers
2
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-add-module-exports - npm Package Compare versions

Comparing version 0.3.1 to 0.3.2

51

lib/index.js
'use strict';
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

@@ -13,4 +15,3 @@

module.exports = function (_ref) {
var template = _ref.template,
types = _ref.types;
var template = _ref.template;

@@ -20,9 +21,3 @@ var pluginOptions = void 0;

AssignmentExpression: function AssignmentExpression(path) {
// Not `object.anything`, skip
if (!path.get('left.object').node) {
return;
}
var name = path.get('left.object.name').node + '.' + path.get('left.property.name').node;
if (name === 'exports.default') {
if (path.get('left').matchesPattern('exports.default')) {
var finder = new ExportsFinder(path);

@@ -81,7 +76,7 @@ if (!finder.isOnlyExportsDefault()) {

if (path.isVariableDeclaration()) {
_this.findExport(path.get('declarations.0'), 'init');
_this.findExports(path.get('declarations.0'), 'init');
} else if (path.isExpressionStatement() && path.get('expression').isAssignmentExpression()) {
_this.findExports(path);
} else {
if (path.isExpressionStatement() && path.get('expression').isAssignmentExpression()) {
_this.findExport(path);
}
_this.findExportsInCallExpression(path);
}

@@ -92,4 +87,4 @@ });

}, {
key: 'findExport',
value: function findExport(path) {
key: 'findExports',
value: function findExports(path) {
var property = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'expression';

@@ -107,3 +102,3 @@

this.hasExportsDefault = true;
} else {
} else if (propertyName !== '__esModule') {
this.hasExportsNamed = true;

@@ -115,5 +110,27 @@ }

}
return null;
}
}, {
key: 'findExportsInCallExpression',
value: function findExportsInCallExpression(path) {
var self = this;
path.traverse({
CallExpression: function CallExpression(path) {
if (!path.get('callee').matchesPattern('Object.defineProperty')) {
return;
}
var _path$get = path.get('arguments'),
_path$get2 = _slicedToArray(_path$get, 2),
identifier = _path$get2[0],
prop = _path$get2[1];
var objectName = identifier.get('name').node;
var propertyName = prop.get('value').node;
if (objectName === 'exports' && propertyName !== '__esModule') {
self.hasExportsNamed = true;
}
}
});
}
}, {
key: 'isAmd',

@@ -120,0 +137,0 @@ value: function isAmd() {

{
"name": "babel-plugin-add-module-exports",
"version": "0.3.1",
"version": "0.3.2",
"description": "Fix babel/babel#2212",

@@ -17,25 +17,28 @@ "main": "lib",

"devDependencies": {
"babel-cli": "^6.5.1",
"babel-core": "^6.5.1",
"babel-plugin-rewire": "^1.0.0-rc-3",
"babel-plugin-transform-export-extensions": "^6.5.0",
"babel-cli": "^6.26.0",
"babel-core": "^6.26.3",
"babel-eslint": "^8.2.6",
"babel-plugin-rewire": "^1.1.0",
"babel-plugin-transform-export-extensions": "^6.22.0",
"babel-preset-env": "^1.7.0",
"babel-preset-power-assert": "^2.0.0",
"babel-preset-react": "^6.5.0",
"babel-preset-react": "^6.24.1",
"babel-template": "^6.26.0",
"babel-types": "^6.26.0",
"chokidar": "^2.0.4",
"conventional-github-releaser": "^3.1.2",
"eslint": "^5.0.0",
"eslint-config-standard": "^12.0.0-alpha.0",
"eslint-plugin-import": "^2.12.0",
"eslint-plugin-mocha": "^5.0.0",
"eslint": "^5.1.0",
"eslint-config-prettier": "^2.9.0",
"eslint-config-standard": "^11.0.0",
"eslint-plugin-import": "^2.13.0",
"eslint-plugin-node": "^6.0.1",
"eslint-plugin-prettier": "^2.6.2",
"eslint-plugin-promise": "^3.8.0",
"eslint-plugin-standard": "^3.1.0",
"mocha": "^5.2.0",
"npm-statement": "^0.0.0",
"nyc": "^12.0.2",
"power-assert": "^1.2.0"
"power-assert": "^1.6.0",
"prettier": "^1.13.7"
},
"optionalDependencies": {
"chokidar": "^2.0.4"
},
"keywords": [

@@ -42,0 +45,0 @@ "babel-plugin",

Sorry, the diff of this file is not supported yet

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