babel-plugin-resolver
Advanced tools
Comparing version 0.0.7 to 0.1.0
@@ -1,2 +0,4 @@ | ||
var _ = require('lodash'); | ||
var find = require('lodash/find'); | ||
var isArray = require('lodash/isArray'); | ||
var isObject = require('lodash/isObject'); | ||
@@ -7,7 +9,7 @@ // Sadly this is the only way to get a plugin's options from within `manipulateOptions`... | ||
module.exports = function getPluginOptsFromBabelOpts(babelOpts) { | ||
var plugin = _.find(babelOpts.plugins, function (plugin) { | ||
var plugin = find(babelOpts.plugins, function (plugin) { | ||
// hack: assume it's the correct plugin if it's options have a `resolveDirs` property | ||
return _.isArray(plugin) && | ||
_.isObject(plugin[1]) && | ||
_.isArray(plugin[1].resolveDirs); | ||
return isArray(plugin) && | ||
isObject(plugin[1]) && | ||
isArray(plugin[1].resolveDirs); | ||
}); | ||
@@ -14,0 +16,0 @@ |
var resolve = require('path').resolve; | ||
var createBabelResolver = require('babel-resolver'); | ||
var findNodeModulesPaths = require('babel-resolver/lib/findNodeModulesPaths'); | ||
var getFilenameFromBabelOpts = require('./getFilenameFromBabelOpts'); | ||
var getPluginOptsFromBabelOpts = require('./getPluginOptsFromBabelOpts'); | ||
@@ -12,4 +13,7 @@ var getAbsoluteDirsFromInputDirs = require('./getAbsoluteDirsFromInputDirs'); | ||
if (!resolver) { | ||
var filename = getFilenameFromBabelOpts(babelOpts); | ||
if (!filename) { return null; } | ||
var pluginOpts = getPluginOptsFromBabelOpts(babelOpts); | ||
var nodeModulesPaths = findNodeModulesPaths(babelOpts.filename); | ||
var nodeModulesPaths = findNodeModulesPaths(filename); | ||
var appRootPath = resolve(nodeModulesPaths[0], '..'); | ||
@@ -16,0 +20,0 @@ var absoluteDirs = getAbsoluteDirsFromInputDirs(pluginOpts.resolveDirs, appRootPath); |
{ | ||
"name": "babel-plugin-resolver", | ||
"version": "0.0.7", | ||
"version": "0.1.0", | ||
"description": "Resolve modules from any directory.", | ||
@@ -37,3 +37,3 @@ "main": "lib/ResolverPlugin.js", | ||
"babel-resolver": "^0.0.18", | ||
"lodash": "^3.10.1" | ||
"lodash": "^4.6.0" | ||
}, | ||
@@ -40,0 +40,0 @@ "devDependencies": { |
@@ -26,3 +26,3 @@ # Babel Resolver Plugin [![NPM version][npm-image]][npm-url] [![Build status][travis-image]][travis-url] | ||
"presets": ["es2015"], | ||
"plugins": [["resolver", { "resolveDirs": ["src"] }]] | ||
"plugins": [["resolver", {"resolveDirs": ["src"]}]] | ||
} | ||
@@ -64,3 +64,3 @@ ``` | ||
"presets": ["es2015"], | ||
"plugins": [["resolver", { "resolveDirs": ["src", "src/lib"] }]] | ||
"plugins": [["resolver", {"resolveDirs": ["src", "src/lib"]}]] | ||
} | ||
@@ -96,3 +96,3 @@ ``` | ||
npm i babel-plugin-resolver --save | ||
rm -rf ~/.babel.json | ||
rm -f ~/.babel.json | ||
``` | ||
@@ -99,0 +99,0 @@ |
Sorry, the diff of this file is not supported yet
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
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
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
9607
21
101
1
+ Addedlodash@4.17.21(transitive)
- Removedlodash@3.10.1(transitive)
Updatedlodash@^4.6.0