rollup-plugin-node-resolve
Advanced tools
Comparing version 5.0.4 to 5.1.0
# rollup-plugin-node-resolve changelog | ||
## 5.1.0 (2019-06-22) | ||
* Fix path fragment inputs ([#229](https://github.com/rollup/rollup-plugin-node-resolve/pull/229) by @bterlson) | ||
## 5.0.4 (2019-06-22) | ||
@@ -4,0 +8,0 @@ |
@@ -130,4 +130,30 @@ 'use strict'; | ||
const resolveIdAsync = (file, opts) => new Promise((fulfil, reject) => resolveId(file, opts, (err, contents) => err ? reject(err) : fulfil(contents))); | ||
const resolveIdAsync = (file, opts) => new Promise((fulfil, reject) => resolveId(file, opts, (err, contents) => err ? reject(err) : fulfil(contents))); // Resolve module specifiers in order. Promise resolves to the first | ||
// module that resolves successfully, or the error that resulted from | ||
// the last attempted module resolution. | ||
function resolveImportSpecifiers(importSpecifierList, resolveOptions) { | ||
let p = Promise.resolve(); | ||
for (let i = 0; i < importSpecifierList.length; i++) { | ||
p = p.then(v => { | ||
// if we've already resolved to something, just return it. | ||
if (v) return v; | ||
return resolveIdAsync(importSpecifierList[i], resolveOptions); | ||
}); | ||
if (i < importSpecifierList.length - 1) { | ||
// swallow MODULE_NOT_FOUND errors from all but the last resolution | ||
p = p.catch(err => { | ||
if (err.code !== 'MODULE_NOT_FOUND') { | ||
throw err; | ||
} | ||
}); | ||
} | ||
} | ||
return p; | ||
} | ||
function nodeResolve(options = {}) { | ||
@@ -311,21 +337,28 @@ const mainFields = getMainFields(options); | ||
const importeeIsBuiltin = builtins.has(importee); | ||
const forceLocalLookup = importeeIsBuiltin && (!preferBuiltins || !isPreferBuiltinsSet); | ||
let importSpecifier = importee; | ||
const importSpecifierList = []; | ||
if (forceLocalLookup) { | ||
// need to attempt to look up a local module | ||
importSpecifier += '/'; | ||
if (importer === undefined && !importee[0].match(/^\.?\.?\//)) { | ||
// For module graph roots (i.e. when importer is undefined), we | ||
// need to handle 'path fragments` like `foo/bar` that are commonly | ||
// found in rollup config files. If importee doesn't look like a | ||
// relative or absolute path, we make it relative and attempt to | ||
// resolve it. If we don't find anything, we try resolving it as we | ||
// got it. | ||
importSpecifierList.push('./' + importee); | ||
} | ||
return resolveIdAsync(importSpecifier, Object.assign(resolveOptions, customResolveOptions)).catch(err => { | ||
if (forceLocalLookup && err.code === 'MODULE_NOT_FOUND') { | ||
// didn't find a local module, so fall back to the importee | ||
// (i.e. the builtin's name) | ||
return importee; | ||
} // some other error, just forward it | ||
const importeeIsBuiltin = builtins.has(importee); | ||
if (importeeIsBuiltin && (!preferBuiltins || !isPreferBuiltinsSet)) { | ||
// The `resolve` library will not resolve packages with the same | ||
// name as a node built-in module. If we're resolving something | ||
// that's a builtin, and we don't prefer to find built-ins, we | ||
// first try to look up a local module with that name. If we don't | ||
// find anything, we resolve the builtin which just returns back | ||
// the built-in's name. | ||
importSpecifierList.push(importee + '/'); | ||
} | ||
throw err; | ||
}).then(resolved => { | ||
importSpecifierList.push(importee); | ||
return resolveImportSpecifiers(importSpecifierList, Object.assign(resolveOptions, customResolveOptions)).then(resolved => { | ||
if (resolved && packageBrowserField) { | ||
@@ -332,0 +365,0 @@ if (Object.prototype.hasOwnProperty.call(packageBrowserField, resolved)) { |
@@ -126,4 +126,30 @@ import { dirname, join, resolve, normalize, sep, extname } from 'path'; | ||
const resolveIdAsync = (file, opts) => new Promise((fulfil, reject) => resolveId(file, opts, (err, contents) => err ? reject(err) : fulfil(contents))); | ||
const resolveIdAsync = (file, opts) => new Promise((fulfil, reject) => resolveId(file, opts, (err, contents) => err ? reject(err) : fulfil(contents))); // Resolve module specifiers in order. Promise resolves to the first | ||
// module that resolves successfully, or the error that resulted from | ||
// the last attempted module resolution. | ||
function resolveImportSpecifiers(importSpecifierList, resolveOptions) { | ||
let p = Promise.resolve(); | ||
for (let i = 0; i < importSpecifierList.length; i++) { | ||
p = p.then(v => { | ||
// if we've already resolved to something, just return it. | ||
if (v) return v; | ||
return resolveIdAsync(importSpecifierList[i], resolveOptions); | ||
}); | ||
if (i < importSpecifierList.length - 1) { | ||
// swallow MODULE_NOT_FOUND errors from all but the last resolution | ||
p = p.catch(err => { | ||
if (err.code !== 'MODULE_NOT_FOUND') { | ||
throw err; | ||
} | ||
}); | ||
} | ||
} | ||
return p; | ||
} | ||
function nodeResolve(options = {}) { | ||
@@ -307,21 +333,28 @@ const mainFields = getMainFields(options); | ||
const importeeIsBuiltin = builtins.has(importee); | ||
const forceLocalLookup = importeeIsBuiltin && (!preferBuiltins || !isPreferBuiltinsSet); | ||
let importSpecifier = importee; | ||
const importSpecifierList = []; | ||
if (forceLocalLookup) { | ||
// need to attempt to look up a local module | ||
importSpecifier += '/'; | ||
if (importer === undefined && !importee[0].match(/^\.?\.?\//)) { | ||
// For module graph roots (i.e. when importer is undefined), we | ||
// need to handle 'path fragments` like `foo/bar` that are commonly | ||
// found in rollup config files. If importee doesn't look like a | ||
// relative or absolute path, we make it relative and attempt to | ||
// resolve it. If we don't find anything, we try resolving it as we | ||
// got it. | ||
importSpecifierList.push('./' + importee); | ||
} | ||
return resolveIdAsync(importSpecifier, Object.assign(resolveOptions, customResolveOptions)).catch(err => { | ||
if (forceLocalLookup && err.code === 'MODULE_NOT_FOUND') { | ||
// didn't find a local module, so fall back to the importee | ||
// (i.e. the builtin's name) | ||
return importee; | ||
} // some other error, just forward it | ||
const importeeIsBuiltin = builtins.has(importee); | ||
if (importeeIsBuiltin && (!preferBuiltins || !isPreferBuiltinsSet)) { | ||
// The `resolve` library will not resolve packages with the same | ||
// name as a node built-in module. If we're resolving something | ||
// that's a builtin, and we don't prefer to find built-ins, we | ||
// first try to look up a local module with that name. If we don't | ||
// find anything, we resolve the builtin which just returns back | ||
// the built-in's name. | ||
importSpecifierList.push(importee + '/'); | ||
} | ||
throw err; | ||
}).then(resolved => { | ||
importSpecifierList.push(importee); | ||
return resolveImportSpecifiers(importSpecifierList, Object.assign(resolveOptions, customResolveOptions)).then(resolved => { | ||
if (resolved && packageBrowserField) { | ||
@@ -328,0 +361,0 @@ if (Object.prototype.hasOwnProperty.call(packageBrowserField, resolved)) { |
{ | ||
"name": "rollup-plugin-node-resolve", | ||
"description": "Bundle third-party dependencies in node_modules", | ||
"version": "5.0.4", | ||
"version": "5.1.0", | ||
"devDependencies": { | ||
@@ -10,3 +10,3 @@ "@babel/core": "^7.4.5", | ||
"es5-ext": "^0.10.50", | ||
"eslint": "^6.0.0", | ||
"eslint": "^5.16.0", | ||
"mocha": "^6.1.4", | ||
@@ -13,0 +13,0 @@ "rollup": "^1.16.1", |
@@ -80,2 +80,28 @@ import {dirname, extname, join, normalize, resolve, sep} from 'path'; | ||
// Resolve module specifiers in order. Promise resolves to the first | ||
// module that resolves successfully, or the error that resulted from | ||
// the last attempted module resolution. | ||
function resolveImportSpecifiers (importSpecifierList, resolveOptions) { | ||
let p = Promise.resolve(); | ||
for (let i = 0; i < importSpecifierList.length; i++) { | ||
p = p.then(v => { | ||
// if we've already resolved to something, just return it. | ||
if (v) return v; | ||
return resolveIdAsync(importSpecifierList[i], resolveOptions); | ||
}); | ||
if (i < importSpecifierList.length - 1) { | ||
// swallow MODULE_NOT_FOUND errors from all but the last resolution | ||
p = p.catch(err => { | ||
if (err.code !== 'MODULE_NOT_FOUND') { | ||
throw err; | ||
} | ||
}); | ||
} | ||
} | ||
return p; | ||
} | ||
export default function nodeResolve ( options = {} ) { | ||
@@ -242,25 +268,32 @@ const mainFields = getMainFields(options); | ||
const importSpecifierList = []; | ||
if (importer === undefined && !importee[0].match(/^\.?\.?\//)) { | ||
// For module graph roots (i.e. when importer is undefined), we | ||
// need to handle 'path fragments` like `foo/bar` that are commonly | ||
// found in rollup config files. If importee doesn't look like a | ||
// relative or absolute path, we make it relative and attempt to | ||
// resolve it. If we don't find anything, we try resolving it as we | ||
// got it. | ||
importSpecifierList.push('./' + importee); | ||
} | ||
const importeeIsBuiltin = builtins.has(importee); | ||
const forceLocalLookup = importeeIsBuiltin && (!preferBuiltins || !isPreferBuiltinsSet); | ||
let importSpecifier = importee; | ||
if (forceLocalLookup) { | ||
// need to attempt to look up a local module | ||
importSpecifier += '/'; | ||
if (importeeIsBuiltin && (!preferBuiltins || !isPreferBuiltinsSet)) { | ||
// The `resolve` library will not resolve packages with the same | ||
// name as a node built-in module. If we're resolving something | ||
// that's a builtin, and we don't prefer to find built-ins, we | ||
// first try to look up a local module with that name. If we don't | ||
// find anything, we resolve the builtin which just returns back | ||
// the built-in's name. | ||
importSpecifierList.push(importee + '/'); | ||
} | ||
return resolveIdAsync( | ||
importSpecifier, | ||
Object.assign( resolveOptions, customResolveOptions ) | ||
importSpecifierList.push(importee); | ||
return resolveImportSpecifiers( | ||
importSpecifierList, | ||
Object.assign(resolveOptions, customResolveOptions) | ||
) | ||
.catch(err => { | ||
if (forceLocalLookup && err.code === 'MODULE_NOT_FOUND') { | ||
// didn't find a local module, so fall back to the importee | ||
// (i.e. the builtin's name) | ||
return importee; | ||
} | ||
// some other error, just forward it | ||
throw err; | ||
}) | ||
.then(resolved => { | ||
@@ -267,0 +300,0 @@ if ( resolved && packageBrowserField ) { |
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
54391
1039