rollup-plugin-node-resolve
Advanced tools
Comparing version 5.0.2 to 5.0.3
# rollup-plugin-node-resolve changelog | ||
## 5.0.3 (2019-06-16) | ||
* Make empty.js a virtual module ([#224](https://github.com/rollup/rollup-plugin-node-resolve/pull/224) by @manucorporat) | ||
## 5.0.2 (2019-06-13) | ||
@@ -4,0 +8,0 @@ |
@@ -54,4 +54,4 @@ 'use strict'; | ||
const builtins = builtinList.reduce((set, id) => set.add(id), new Set()); | ||
const ES6_BROWSER_EMPTY = path.resolve(__dirname, '../src/empty.js'); // It is important that .mjs occur before .js so that Rollup will interpret npm modules | ||
const builtins = new Set(builtinList); | ||
const ES6_BROWSER_EMPTY = '\0node-resolve:empty.js'; // It is important that .mjs occur before .js so that Rollup will interpret npm modules | ||
// which deploy both ESM .mjs and CommonJS .js files as ESM. | ||
@@ -142,3 +142,3 @@ | ||
const only = Array.isArray(options.only) ? options.only.map(o => o instanceof RegExp ? o : new RegExp('^' + String(o).replace(/[\\^$*+?.()|[\]{}]/g, '\\$&') + '$')) : null; | ||
const browserMapCache = {}; | ||
const browserMapCache = new Map(); | ||
@@ -245,2 +245,6 @@ if (options.skip) { | ||
resolveId(importee, importer) { | ||
if (importee === ES6_BROWSER_EMPTY) { | ||
return importee; | ||
} | ||
if (/\0/.test(importee)) return null; // ignore IDs with null character, these belong to other plugins | ||
@@ -255,5 +259,6 @@ | ||
if (useBrowserOverrides && browserMapCache[importer]) { | ||
const browser = browserMapCache.get(importer); | ||
if (useBrowserOverrides && browser) { | ||
const resolvedImportee = path.resolve(basedir, importee); | ||
const browser = browserMapCache[importer]; | ||
@@ -264,4 +269,6 @@ if (browser[importee] === false || browser[resolvedImportee] === false) { | ||
if (browser[importee] || browser[resolvedImportee] || browser[resolvedImportee + '.js'] || browser[resolvedImportee + '.json']) { | ||
importee = browser[importee] || browser[resolvedImportee] || browser[resolvedImportee + '.js'] || browser[resolvedImportee + '.json']; | ||
const browserImportee = browser[importee] || browser[resolvedImportee] || browser[resolvedImportee + '.js'] || browser[resolvedImportee + '.json']; | ||
if (browserImportee) { | ||
importee = browserImportee; | ||
} | ||
@@ -273,3 +280,3 @@ } | ||
if (id[0] === '@' && parts.length) { | ||
if (id[0] === '@' && parts.length > 0) { | ||
// scoped packages | ||
@@ -333,3 +340,3 @@ id += `/${parts.shift()}`; | ||
if (!packageBrowserField[resolved]) { | ||
browserMapCache[resolved] = packageBrowserField; | ||
browserMapCache.set(resolved, packageBrowserField); | ||
return ES6_BROWSER_EMPTY; | ||
@@ -341,3 +348,3 @@ } | ||
browserMapCache[resolved] = packageBrowserField; | ||
browserMapCache.set(resolved, packageBrowserField); | ||
} | ||
@@ -375,2 +382,10 @@ | ||
}).catch(() => null); | ||
}, | ||
load(importee) { | ||
if (importee === ES6_BROWSER_EMPTY) { | ||
return 'export default {};'; | ||
} | ||
return null; | ||
} | ||
@@ -377,0 +392,0 @@ |
@@ -50,4 +50,4 @@ import { dirname, join, resolve, normalize, sep, extname } from 'path'; | ||
const builtins = builtinList.reduce((set, id) => set.add(id), new Set()); | ||
const ES6_BROWSER_EMPTY = resolve(__dirname, '../src/empty.js'); // It is important that .mjs occur before .js so that Rollup will interpret npm modules | ||
const builtins = new Set(builtinList); | ||
const ES6_BROWSER_EMPTY = '\0node-resolve:empty.js'; // It is important that .mjs occur before .js so that Rollup will interpret npm modules | ||
// which deploy both ESM .mjs and CommonJS .js files as ESM. | ||
@@ -138,3 +138,3 @@ | ||
const only = Array.isArray(options.only) ? options.only.map(o => o instanceof RegExp ? o : new RegExp('^' + String(o).replace(/[\\^$*+?.()|[\]{}]/g, '\\$&') + '$')) : null; | ||
const browserMapCache = {}; | ||
const browserMapCache = new Map(); | ||
@@ -241,2 +241,6 @@ if (options.skip) { | ||
resolveId(importee, importer) { | ||
if (importee === ES6_BROWSER_EMPTY) { | ||
return importee; | ||
} | ||
if (/\0/.test(importee)) return null; // ignore IDs with null character, these belong to other plugins | ||
@@ -251,5 +255,6 @@ | ||
if (useBrowserOverrides && browserMapCache[importer]) { | ||
const browser = browserMapCache.get(importer); | ||
if (useBrowserOverrides && browser) { | ||
const resolvedImportee = resolve(basedir, importee); | ||
const browser = browserMapCache[importer]; | ||
@@ -260,4 +265,6 @@ if (browser[importee] === false || browser[resolvedImportee] === false) { | ||
if (browser[importee] || browser[resolvedImportee] || browser[resolvedImportee + '.js'] || browser[resolvedImportee + '.json']) { | ||
importee = browser[importee] || browser[resolvedImportee] || browser[resolvedImportee + '.js'] || browser[resolvedImportee + '.json']; | ||
const browserImportee = browser[importee] || browser[resolvedImportee] || browser[resolvedImportee + '.js'] || browser[resolvedImportee + '.json']; | ||
if (browserImportee) { | ||
importee = browserImportee; | ||
} | ||
@@ -269,3 +276,3 @@ } | ||
if (id[0] === '@' && parts.length) { | ||
if (id[0] === '@' && parts.length > 0) { | ||
// scoped packages | ||
@@ -329,3 +336,3 @@ id += `/${parts.shift()}`; | ||
if (!packageBrowserField[resolved]) { | ||
browserMapCache[resolved] = packageBrowserField; | ||
browserMapCache.set(resolved, packageBrowserField); | ||
return ES6_BROWSER_EMPTY; | ||
@@ -337,3 +344,3 @@ } | ||
browserMapCache[resolved] = packageBrowserField; | ||
browserMapCache.set(resolved, packageBrowserField); | ||
} | ||
@@ -371,2 +378,10 @@ | ||
}).catch(() => null); | ||
}, | ||
load(importee) { | ||
if (importee === ES6_BROWSER_EMPTY) { | ||
return 'export default {};'; | ||
} | ||
return null; | ||
} | ||
@@ -373,0 +388,0 @@ |
{ | ||
"name": "rollup-plugin-node-resolve", | ||
"description": "Bundle third-party dependencies in node_modules", | ||
"version": "5.0.2", | ||
"version": "5.0.3", | ||
"devDependencies": { | ||
@@ -6,0 +6,0 @@ "@babel/core": "^7.4.5", |
@@ -9,5 +9,5 @@ import {dirname, extname, join, normalize, resolve, sep} from 'path'; | ||
const builtins = builtinList.reduce((set, id) => set.add(id), new Set()); | ||
const builtins = new Set(builtinList); | ||
const ES6_BROWSER_EMPTY = resolve( __dirname, '../src/empty.js' ); | ||
const ES6_BROWSER_EMPTY = '\0node-resolve:empty.js'; | ||
// It is important that .mjs occur before .js so that Rollup will interpret npm modules | ||
@@ -95,3 +95,3 @@ // which deploy both ESM .mjs and CommonJS .js files as ESM. | ||
: null; | ||
const browserMapCache = {}; | ||
const browserMapCache = new Map(); | ||
@@ -184,2 +184,6 @@ if ( options.skip ) { | ||
resolveId ( importee, importer ) { | ||
if (importee === ES6_BROWSER_EMPTY) { | ||
return importee; | ||
} | ||
if ( /\0/.test( importee ) ) return null; // ignore IDs with null character, these belong to other plugins | ||
@@ -194,10 +198,11 @@ | ||
// https://github.com/defunctzombie/package-browser-field-spec | ||
if (useBrowserOverrides && browserMapCache[importer]) { | ||
const browser = browserMapCache.get(importer); | ||
if (useBrowserOverrides && browser) { | ||
const resolvedImportee = resolve( basedir, importee ); | ||
const browser = browserMapCache[importer]; | ||
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']; | ||
const browserImportee = browser[importee] || browser[resolvedImportee] || browser[resolvedImportee + '.js'] || browser[resolvedImportee + '.json']; | ||
if (browserImportee) { | ||
importee = browserImportee; | ||
} | ||
@@ -209,3 +214,3 @@ } | ||
if ( id[0] === '@' && parts.length ) { | ||
if ( id[0] === '@' && parts.length > 0 ) { | ||
// scoped packages | ||
@@ -269,3 +274,3 @@ id += `/${parts.shift()}`; | ||
if (!packageBrowserField[resolved]) { | ||
browserMapCache[resolved] = packageBrowserField; | ||
browserMapCache.set(resolved, packageBrowserField); | ||
return ES6_BROWSER_EMPTY; | ||
@@ -275,3 +280,3 @@ } | ||
} | ||
browserMapCache[resolved] = packageBrowserField; | ||
browserMapCache.set(resolved, packageBrowserField); | ||
} | ||
@@ -308,4 +313,11 @@ | ||
.catch(() => null); | ||
} | ||
}, | ||
load ( importee ) { | ||
if ( importee === ES6_BROWSER_EMPTY ) { | ||
return 'export default {};'; | ||
} | ||
return null; | ||
}, | ||
}; | ||
} |
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
50107
959
7