babel-plugin-import
Advanced tools
Comparing version 1.6.3 to 1.6.4
@@ -34,3 +34,3 @@ "use strict"; | ||
if (_plugin[method]) { | ||
_plugin[method].apply(_plugin, [].concat(_toConsumableArray(args), [context])); | ||
_plugin[method].apply(_plugin, _toConsumableArray(args).concat([context])); | ||
} | ||
@@ -54,29 +54,33 @@ } | ||
function Program(path, _ref2) { | ||
var _ref2$opts = _ref2.opts, | ||
opts = _ref2$opts === void 0 ? {} : _ref2$opts; | ||
var Program = { | ||
enter: function enter(path, _ref2) { | ||
var _ref2$opts = _ref2.opts, | ||
opts = _ref2$opts === void 0 ? {} : _ref2$opts; | ||
// Init plugin instances once. | ||
if (!plugins) { | ||
if (Array.isArray(opts)) { | ||
plugins = opts.map(function (_ref3) { | ||
var libraryName = _ref3.libraryName, | ||
libraryDirectory = _ref3.libraryDirectory, | ||
style = _ref3.style, | ||
camel2DashComponentName = _ref3.camel2DashComponentName, | ||
camel2UnderlineComponentName = _ref3.camel2UnderlineComponentName, | ||
fileName = _ref3.fileName, | ||
customName = _ref3.customName; | ||
(0, _assert.default)(libraryName, 'libraryName should be provided'); | ||
return new _Plugin.default(libraryName, libraryDirectory, style, camel2DashComponentName, camel2UnderlineComponentName, fileName, customName, types); | ||
}); | ||
} else { | ||
(0, _assert.default)(opts.libraryName, 'libraryName should be provided'); | ||
plugins = [new _Plugin.default(opts.libraryName, opts.libraryDirectory, opts.style, opts.camel2DashComponentName, opts.camel2UnderlineComponentName, opts.fileName, opts.customName, types)]; | ||
// Init plugin instances once. | ||
if (!plugins) { | ||
if (Array.isArray(opts)) { | ||
plugins = opts.map(function (_ref3) { | ||
var libraryName = _ref3.libraryName, | ||
libraryDirectory = _ref3.libraryDirectory, | ||
style = _ref3.style, | ||
camel2DashComponentName = _ref3.camel2DashComponentName, | ||
camel2UnderlineComponentName = _ref3.camel2UnderlineComponentName, | ||
fileName = _ref3.fileName, | ||
customName = _ref3.customName; | ||
(0, _assert.default)(libraryName, 'libraryName should be provided'); | ||
return new _Plugin.default(libraryName, libraryDirectory, style, camel2DashComponentName, camel2UnderlineComponentName, fileName, customName, types); | ||
}); | ||
} else { | ||
(0, _assert.default)(opts.libraryName, 'libraryName should be provided'); | ||
plugins = [new _Plugin.default(opts.libraryName, opts.libraryDirectory, opts.style, opts.camel2DashComponentName, opts.camel2UnderlineComponentName, opts.fileName, opts.customName, types)]; | ||
} | ||
} | ||
applyInstance('ProgramEnter', arguments, this); // eslint-disable-line | ||
}, | ||
exit: function exit() { | ||
applyInstance('ProgramExit', arguments, this); // eslint-disable-line | ||
} | ||
applyInstance('Program', arguments, this); // eslint-disable-line | ||
} | ||
}; | ||
var methods = ['ImportDeclaration', 'CallExpression', 'MemberExpression', 'Property', 'VariableDeclarator', 'LogicalExpression', 'ConditionalExpression', 'IfStatement', 'ExpressionStatement', 'ReturnStatement', 'ExportDefaultDeclaration', 'BinaryExpression', 'NewExpression']; | ||
@@ -83,0 +87,0 @@ var ret = { |
@@ -111,9 +111,17 @@ "use strict"; | ||
}, { | ||
key: "Program", | ||
value: function Program() { | ||
key: "ProgramEnter", | ||
value: function ProgramEnter() { | ||
this.specified = Object.create(null); | ||
this.libraryObjs = Object.create(null); | ||
this.selectedMethods = Object.create(null); | ||
this.pathsToRemove = []; | ||
} | ||
}, { | ||
key: "ProgramExit", | ||
value: function ProgramExit() { | ||
this.pathsToRemove.forEach(function (p) { | ||
return p.remove(); | ||
}); | ||
} | ||
}, { | ||
key: "ImportDeclaration", | ||
@@ -138,3 +146,3 @@ value: function ImportDeclaration(path) { | ||
}); | ||
path.remove(); | ||
this.pathsToRemove.push(path); | ||
} | ||
@@ -141,0 +149,0 @@ } |
{ | ||
"name": "babel-plugin-import", | ||
"version": "1.6.3", | ||
"version": "1.6.4", | ||
"description": "Component modular import plugin for babel.", | ||
@@ -12,3 +12,3 @@ "repository": { | ||
"build": "rm -rf lib && ./node_modules/.bin/babel src --out-dir lib --ignore __tests__", | ||
"test": "node_modules/.bin/babel-istanbul cover node_modules/.bin/_mocha -- --require babel-register --no-timeouts", | ||
"test": "node_modules/.bin/babel-istanbul cover node_modules/.bin/_mocha -- --require @babel/register --no-timeouts", | ||
"debug": "mocha --require @babel/register --require @babel/polyfill --no-timeouts", | ||
@@ -31,3 +31,5 @@ "lint": "eslint --ext .js src", | ||
"@babel/polyfill": "^7.0.0-beta.34", | ||
"@babel/preset-react": "^7.0.0-beta.40", | ||
"@babel/register": "^7.0.0-beta.34", | ||
"babel-core": "^7.0.0-0", | ||
"babel-istanbul": "^0.12.2", | ||
@@ -34,0 +36,0 @@ "babel-preset-umi": "^0.2.0", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
17334
319
16
1