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

babel-plugin-resolver

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-resolver - npm Package Compare versions

Comparing version 0.0.7 to 0.1.0

lib/getFilenameFromBabelOpts.js

12

lib/getPluginOptsFromBabelOpts.js

@@ -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

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