rollup-plugin-node-resolve
Advanced tools
Comparing version 3.0.2 to 3.0.3
# rollup-plugin-node-resolve changelog | ||
## 3.0.3 | ||
* Fix [#130](https://github.com/rollup/rollup-plugin-node-resolve/issues/130) and [#131](https://github.com/rollup/rollup-plugin-node-resolve/issues/131) | ||
## 3.0.2 | ||
@@ -4,0 +8,0 @@ |
@@ -18,2 +18,3 @@ 'use strict'; | ||
}; // eslint-disable-line no-console | ||
var exts = [ '.js', '.json', '.node' ]; | ||
@@ -52,9 +53,10 @@ function nodeResolve ( options ) { | ||
if (options.browser && browserMapCache[importer]) { | ||
var resolvedImportee = path.resolve( path.dirname( importer ), importee ); | ||
var browser = browserMapCache[importer]; | ||
if (browser[importee]) { | ||
importee = browser[importee]; | ||
} | ||
if (browser[importee] === false) { | ||
if (browser[importee] === false || browser[resolvedImportee] === false) { | ||
return ES6_BROWSER_EMPTY; | ||
} | ||
if (browser[importee] || browser[resolvedImportee] || browser[resolvedImportee + '.js'] || browser[resolvedImportee + '.json']) { | ||
importee = browser[importee] || browser[resolvedImportee] || browser[resolvedImportee + '.js'] || browser[resolvedImportee + '.json']; | ||
} | ||
} | ||
@@ -82,7 +84,18 @@ | ||
basedir: path.dirname( importer ), | ||
packageFilter: function packageFilter ( pkg ) { | ||
packageFilter: function packageFilter ( pkg, pkgPath ) { | ||
var pkgRoot = path.dirname( pkgPath ); | ||
if (options.browser && typeof pkg[ 'browser' ] === 'object') { | ||
packageBrowserField = Object.keys(pkg[ 'browser' ]).reduce(function (browser, key) { | ||
browser[ key ] = pkg[ 'browser' ][key]; | ||
if (key[0] === '.' && !path.extname(key)) { browser[ key + '.js'] = browser[ key + '.json' ] = browser[ key ]; } | ||
var resolved = pkg[ 'browser' ][ key ] === false ? false : path.resolve( pkgRoot, pkg[ 'browser' ][ key ] ); | ||
browser[ key ] = resolved; | ||
if ( key[0] === '.' ) { | ||
var absoluteKey = path.resolve( pkgRoot, key ); | ||
browser[ absoluteKey ] = resolved; | ||
if ( !path.extname(key) ) { | ||
exts.reduce( function ( browser, ext ) { | ||
browser[ absoluteKey + ext ] = browser[ key ]; | ||
return browser; | ||
}, browser ); | ||
} | ||
} | ||
return browser; | ||
@@ -94,4 +107,2 @@ }, {}); | ||
pkg[ 'main' ] = pkg[ 'browser' ]; | ||
} else if (options.browser && typeof pkg[ 'browser' ] === 'object' && pkg[ 'browser' ][ pkg[ 'main' ] ]) { | ||
pkg[ 'main' ] = pkg[ 'browser' ][ pkg[ 'main' ] ]; | ||
} else if ( useModule && pkg[ 'module' ] ) { | ||
@@ -109,3 +120,8 @@ pkg[ 'main' ] = pkg[ 'module' ]; | ||
function ( err, resolved ) { | ||
if (options.browser && packageBrowserField) { browserMapCache[resolved] = packageBrowserField; } | ||
if (options.browser && packageBrowserField) { | ||
if (packageBrowserField[ resolved ]) { | ||
resolved = packageBrowserField[ resolved ]; | ||
} | ||
browserMapCache[resolved] = packageBrowserField; | ||
} | ||
@@ -112,0 +128,0 @@ if ( !disregardResult && !err ) { |
@@ -14,2 +14,3 @@ import { dirname, extname, normalize, resolve, sep } from 'path'; | ||
}; // eslint-disable-line no-console | ||
var exts = [ '.js', '.json', '.node' ]; | ||
@@ -48,9 +49,10 @@ function nodeResolve ( options ) { | ||
if (options.browser && browserMapCache[importer]) { | ||
var resolvedImportee = resolve( dirname( importer ), importee ); | ||
var browser = browserMapCache[importer]; | ||
if (browser[importee]) { | ||
importee = browser[importee]; | ||
} | ||
if (browser[importee] === false) { | ||
if (browser[importee] === false || browser[resolvedImportee] === false) { | ||
return ES6_BROWSER_EMPTY; | ||
} | ||
if (browser[importee] || browser[resolvedImportee] || browser[resolvedImportee + '.js'] || browser[resolvedImportee + '.json']) { | ||
importee = browser[importee] || browser[resolvedImportee] || browser[resolvedImportee + '.js'] || browser[resolvedImportee + '.json']; | ||
} | ||
} | ||
@@ -78,7 +80,18 @@ | ||
basedir: dirname( importer ), | ||
packageFilter: function packageFilter ( pkg ) { | ||
packageFilter: function packageFilter ( pkg, pkgPath ) { | ||
var pkgRoot = dirname( pkgPath ); | ||
if (options.browser && typeof pkg[ 'browser' ] === 'object') { | ||
packageBrowserField = Object.keys(pkg[ 'browser' ]).reduce(function (browser, key) { | ||
browser[ key ] = pkg[ 'browser' ][key]; | ||
if (key[0] === '.' && !extname(key)) { browser[ key + '.js'] = browser[ key + '.json' ] = browser[ key ]; } | ||
var resolved = pkg[ 'browser' ][ key ] === false ? false : resolve( pkgRoot, pkg[ 'browser' ][ key ] ); | ||
browser[ key ] = resolved; | ||
if ( key[0] === '.' ) { | ||
var absoluteKey = resolve( pkgRoot, key ); | ||
browser[ absoluteKey ] = resolved; | ||
if ( !extname(key) ) { | ||
exts.reduce( function ( browser, ext ) { | ||
browser[ absoluteKey + ext ] = browser[ key ]; | ||
return browser; | ||
}, browser ); | ||
} | ||
} | ||
return browser; | ||
@@ -90,4 +103,2 @@ }, {}); | ||
pkg[ 'main' ] = pkg[ 'browser' ]; | ||
} else if (options.browser && typeof pkg[ 'browser' ] === 'object' && pkg[ 'browser' ][ pkg[ 'main' ] ]) { | ||
pkg[ 'main' ] = pkg[ 'browser' ][ pkg[ 'main' ] ]; | ||
} else if ( useModule && pkg[ 'module' ] ) { | ||
@@ -105,3 +116,8 @@ pkg[ 'main' ] = pkg[ 'module' ]; | ||
function ( err, resolved ) { | ||
if (options.browser && packageBrowserField) { browserMapCache[resolved] = packageBrowserField; } | ||
if (options.browser && packageBrowserField) { | ||
if (packageBrowserField[ resolved ]) { | ||
resolved = packageBrowserField[ resolved ]; | ||
} | ||
browserMapCache[resolved] = packageBrowserField; | ||
} | ||
@@ -108,0 +124,0 @@ if ( !disregardResult && !err ) { |
{ | ||
"name": "rollup-plugin-node-resolve", | ||
"description": "Bundle third-party dependencies in node_modules", | ||
"version": "3.0.2", | ||
"version": "3.0.3", | ||
"devDependencies": { | ||
@@ -6,0 +6,0 @@ "buble": "^0.15.2", |
@@ -9,2 +9,3 @@ import { dirname, resolve, extname, normalize, sep } from 'path'; | ||
const CONSOLE_WARN = ( ...args ) => console.warn( ...args ); // eslint-disable-line no-console | ||
const exts = [ '.js', '.json', '.node' ]; | ||
@@ -41,9 +42,10 @@ export default function nodeResolve ( options = {} ) { | ||
if (options.browser && browserMapCache[importer]) { | ||
const resolvedImportee = resolve( dirname( importer ), importee ); | ||
const browser = browserMapCache[importer]; | ||
if (browser[importee]) { | ||
importee = browser[importee]; | ||
} | ||
if (browser[importee] === false) { | ||
if (browser[importee] === false || browser[resolvedImportee] === false) { | ||
return ES6_BROWSER_EMPTY; | ||
} | ||
if (browser[importee] || browser[resolvedImportee] || browser[resolvedImportee + '.js'] || browser[resolvedImportee + '.json']) { | ||
importee = browser[importee] || browser[resolvedImportee] || browser[resolvedImportee + '.js'] || browser[resolvedImportee + '.json']; | ||
} | ||
} | ||
@@ -71,7 +73,18 @@ | ||
basedir: dirname( importer ), | ||
packageFilter ( pkg ) { | ||
packageFilter ( pkg, pkgPath ) { | ||
const pkgRoot = dirname( pkgPath ); | ||
if (options.browser && typeof pkg[ 'browser' ] === 'object') { | ||
packageBrowserField = Object.keys(pkg[ 'browser' ]).reduce((browser, key) => { | ||
browser[ key ] = pkg[ 'browser' ][key]; | ||
if (key[0] === '.' && !extname(key)) browser[ key + '.js'] = browser[ key + '.json' ] = browser[ key ]; | ||
const resolved = pkg[ 'browser' ][ key ] === false ? false : resolve( pkgRoot, pkg[ 'browser' ][ key ] ); | ||
browser[ key ] = resolved; | ||
if ( key[0] === '.' ) { | ||
const absoluteKey = resolve( pkgRoot, key ); | ||
browser[ absoluteKey ] = resolved; | ||
if ( !extname(key) ) { | ||
exts.reduce( ( browser, ext ) => { | ||
browser[ absoluteKey + ext ] = browser[ key ]; | ||
return browser; | ||
}, browser ); | ||
} | ||
} | ||
return browser; | ||
@@ -83,4 +96,2 @@ }, {}); | ||
pkg[ 'main' ] = pkg[ 'browser' ]; | ||
} else if (options.browser && typeof pkg[ 'browser' ] === 'object' && pkg[ 'browser' ][ pkg[ 'main' ] ]) { | ||
pkg[ 'main' ] = pkg[ 'browser' ][ pkg[ 'main' ] ]; | ||
} else if ( useModule && pkg[ 'module' ] ) { | ||
@@ -98,3 +109,8 @@ pkg[ 'main' ] = pkg[ 'module' ]; | ||
( err, resolved ) => { | ||
if (options.browser && packageBrowserField) browserMapCache[resolved] = packageBrowserField; | ||
if (options.browser && packageBrowserField) { | ||
if (packageBrowserField[ resolved ]) { | ||
resolved = packageBrowserField[ resolved ]; | ||
} | ||
browserMapCache[resolved] = packageBrowserField; | ||
} | ||
@@ -101,0 +117,0 @@ if ( !disregardResult && !err ) { |
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
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
22617
411