eslint-import-resolver-webpack
Advanced tools
Comparing version
31
index.js
@@ -5,2 +5,3 @@ var findRoot = require('find-root') | ||
, get = require('lodash.get') | ||
, find = require('array-find') | ||
@@ -64,2 +65,3 @@ var resolveAlias = require('./resolve-alias') | ||
paths: paths, | ||
packageFilter: packageFilter.bind(null, webpackConfig), | ||
}) | ||
@@ -90,1 +92,30 @@ } | ||
} | ||
/** | ||
* webpack defaults: http://webpack.github.io/docs/configuration.html#resolve-packagemains | ||
* @type {Array} | ||
*/ | ||
var defaultMains = [ | ||
'webpack', 'browser', 'web', 'browserify', ['jam', 'main'], 'main', | ||
] | ||
function packageFilter(config, pkg) { | ||
var altMain | ||
// check for rollup-style first | ||
if (pkg['jsnext:main']) { | ||
pkg['main'] = pkg['jsnext:main'] | ||
} else { | ||
// check for configured/default alternative main fields | ||
altMain = find( | ||
get(config, ['resolve', 'packageMains']) || defaultMains, | ||
function (m) { return get(pkg, m) }) | ||
if (altMain) { | ||
pkg['main'] = pkg[altMain] | ||
} | ||
} | ||
return pkg | ||
} |
{ | ||
"name": "eslint-import-resolver-webpack", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "Resolve paths to dependencies, given a webpack.config.js. Plugin for eslint-plugin-import.", | ||
@@ -27,2 +27,3 @@ "main": "index.js", | ||
"dependencies": { | ||
"array-find": "^1.0.0", | ||
"find-root": "^0.1.1", | ||
@@ -29,0 +30,0 @@ "lodash.get": "^3.7.0", |
6229
13.94%119
26.6%4
33.33%+ Added
+ Added