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

@rollup/plugin-node-resolve

Package Overview
Dependencies
Maintainers
4
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rollup/plugin-node-resolve - npm Package Compare versions

Comparing version 8.4.0 to 9.0.0

29

CHANGELOG.md
# @rollup/plugin-node-resolve ChangeLog
## v8.4.0
## v9.0.0
_2020-07-12_
_2020-08-13_
### Features
### Breaking Changes
- feat: preserve search params and hashes (#487)
- feat: support .js imports in TypeScript (#480)
- chore: update dependencies (e632469)
### Updates
- docs: fix named export use in readme (#456)
- docs: correct mainFields valid values (#469)
- refactor: remove deep-freeze from dependencies (#529)
- chore: clean up changelog (84dfddb)
## v8.3.0
## v8.4.0

@@ -31,16 +30,2 @@ _2020-07-12_

## v8.2.0
_2020-07-12_
### Features
- feat: preserve search params and hashes (#487)
- feat: support .js imports in TypeScript (#480)
### Updates
- docs: fix named export use in readme (#456)
- docs: correct mainFields valid values (#469)
## v8.1.0

@@ -47,0 +32,0 @@

@@ -9,3 +9,2 @@ 'use strict';

var builtinList = _interopDefault(require('builtin-modules'));
var deepFreeze = _interopDefault(require('deep-freeze'));
var deepMerge = _interopDefault(require('deepmerge'));

@@ -19,149 +18,2 @@ var isModule = _interopDefault(require('is-module'));

function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
try {
var info = gen[key](arg);
var value = info.value;
} catch (error) {
reject(error);
return;
}
if (info.done) {
resolve(value);
} else {
Promise.resolve(value).then(_next, _throw);
}
}
function _asyncToGenerator(fn) {
return function () {
var self = this,
args = arguments;
return new Promise(function (resolve, reject) {
var gen = fn.apply(self, args);
function _next(value) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
}
function _throw(err) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
}
_next(undefined);
});
};
}
function _slicedToArray(arr, i) {
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
}
function _arrayWithHoles(arr) {
if (Array.isArray(arr)) return arr;
}
function _iterableToArrayLimit(arr, i) {
if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return;
var _arr = [];
var _n = true;
var _d = false;
var _e = undefined;
try {
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
_arr.push(_s.value);
if (i && _arr.length === i) break;
}
} catch (err) {
_d = true;
_e = err;
} finally {
try {
if (!_n && _i["return"] != null) _i["return"]();
} finally {
if (_d) throw _e;
}
}
return _arr;
}
function _unsupportedIterableToArray(o, minLen) {
if (!o) return;
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
var n = Object.prototype.toString.call(o).slice(8, -1);
if (n === "Object" && o.constructor) n = o.constructor.name;
if (n === "Map" || n === "Set") return Array.from(n);
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
}
function _arrayLikeToArray(arr, len) {
if (len == null || len > arr.length) len = arr.length;
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
return arr2;
}
function _nonIterableRest() {
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
function _createForOfIteratorHelper(o) {
if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) {
if (Array.isArray(o) || (o = _unsupportedIterableToArray(o))) {
var i = 0;
var F = function () {};
return {
s: F,
n: function () {
if (i >= o.length) return {
done: true
};
return {
done: false,
value: o[i++]
};
},
e: function (e) {
throw e;
},
f: F
};
}
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
var it,
normalCompletion = true,
didErr = false,
err;
return {
s: function () {
it = o[Symbol.iterator]();
},
n: function () {
var step = it.next();
normalCompletion = step.done;
return step;
},
e: function (e) {
didErr = true;
err = e;
},
f: function () {
try {
if (!normalCompletion && it.return != null) it.return();
} finally {
if (didErr) throw err;
}
}
};
}
const exists = util.promisify(fs__default.exists);

@@ -172,36 +24,31 @@ const readFile = util.promisify(fs__default.readFile);

const onError = error => {
const onError = (error) => {
if (error.code === 'ENOENT') {
return false;
}
throw error;
};
const makeCache = fn => {
const makeCache = (fn) => {
const cache = new Map();
const wrapped = /*#__PURE__*/function () {
var _ref = _asyncToGenerator(function* (param, done) {
if (cache.has(param) === false) {
cache.set(param, fn(param).catch(err => {
const wrapped = async (param, done) => {
if (cache.has(param) === false) {
cache.set(
param,
fn(param).catch((err) => {
cache.delete(param);
throw err;
}));
}
})
);
}
try {
const result = cache.get(param);
const value = yield result;
return done(null, value);
} catch (error) {
return done(error);
}
});
try {
const result = cache.get(param);
const value = await result;
return done(null, value);
} catch (error) {
return done(error);
}
};
return function wrapped(_x, _x2) {
return _ref.apply(this, arguments);
};
}();
wrapped.clear = () => cache.clear();

@@ -212,34 +59,25 @@

const isDirCached = makeCache( /*#__PURE__*/function () {
var _ref2 = _asyncToGenerator(function* (file) {
try {
const stats = yield stat(file);
return stats.isDirectory();
} catch (error) {
return onError(error);
}
});
const isDirCached = makeCache(async (file) => {
try {
const stats = await stat(file);
return stats.isDirectory();
} catch (error) {
return onError(error);
}
});
return function (_x3) {
return _ref2.apply(this, arguments);
};
}());
const isFileCached = makeCache( /*#__PURE__*/function () {
var _ref3 = _asyncToGenerator(function* (file) {
try {
const stats = yield stat(file);
return stats.isFile();
} catch (error) {
return onError(error);
}
});
const isFileCached = makeCache(async (file) => {
try {
const stats = await stat(file);
return stats.isFile();
} catch (error) {
return onError(error);
}
});
return function (_x4) {
return _ref3.apply(this, arguments);
};
}());
const readCachedFile = makeCache(readFile);
const resolveId = util.promisify(resolveModule); // returns the imported package name for bare module imports
const resolveId = util.promisify(resolveModule);
// returns the imported package name for bare module imports
function getPackageName(id) {

@@ -250,46 +88,40 @@ if (id.startsWith('.') || id.startsWith('/')) {

const split = id.split('/'); // @my-scope/my-package/foo.js -> @my-scope/my-package
const split = id.split('/');
// @my-scope/my-package/foo.js -> @my-scope/my-package
// @my-scope/my-package -> @my-scope/my-package
if (split[0][0] === '@') {
return `${split[0]}/${split[1]}`;
} // my-package/foo.js -> my-package
}
// my-package/foo.js -> my-package
// my-package -> my-package
return split[0];
}
function getMainFields(options) {
let mainFields;
if (options.mainFields) {
mainFields = options.mainFields;
({ mainFields } = options);
} else {
mainFields = ['module', 'main'];
}
if (options.browser && mainFields.indexOf('browser') === -1) {
return ['browser'].concat(mainFields);
}
if (!mainFields.length) {
throw new Error('Please ensure at least one `mainFields` value is specified');
}
return mainFields;
}
function getPackageInfo(options) {
const cache = options.cache,
extensions = options.extensions,
pkg = options.pkg,
mainFields = options.mainFields,
preserveSymlinks = options.preserveSymlinks,
useBrowserOverrides = options.useBrowserOverrides;
let pkgPath = options.pkgPath;
const { cache, extensions, pkg, mainFields, preserveSymlinks, useBrowserOverrides } = options;
let { pkgPath } = options;
if (cache.has(pkgPath)) {
return cache.get(pkgPath);
} // browserify/resolve doesn't realpath paths returned in its packageFilter callback
}
// browserify/resolve doesn't realpath paths returned in its packageFilter callback
if (!preserveSymlinks) {

@@ -300,13 +132,19 @@ pkgPath = fs.realpathSync(pkgPath);

const pkgRoot = path.dirname(pkgPath);
const packageInfo = {
// copy as we are about to munge the `main` field of `pkg`.
packageJson: Object.assign({}, pkg),
// path to package.json file
packageJsonPath: pkgPath,
// directory containing the package.json
root: pkgRoot,
// which main field was used during resolution of this module (main, module, or browser)
resolvedMainField: 'main',
// whether the browser map was used to resolve the entry point to this module
browserMappedMain: false,
// the entry point of the module with respect to the selected main field and any

@@ -316,7 +154,6 @@ // relevant browser mappings.

};
let overriddenMain = false;
for (let i = 0; i < mainFields.length; i++) {
const field = mainFields[i];
if (typeof pkg[field] === 'string') {

@@ -334,33 +171,34 @@ pkg.main = pkg[field];

hasPackageEntry: overriddenMain !== false || mainFields.indexOf('main') !== -1,
packageBrowserField: useBrowserOverrides && typeof pkg.browser === 'object' && Object.keys(pkg.browser).reduce((browser, key) => {
let resolved = pkg.browser[key];
if (resolved && resolved[0] === '.') {
resolved = path.resolve(pkgRoot, resolved);
}
/* eslint-disable no-param-reassign */
browser[key] = resolved;
if (key[0] === '.') {
const absoluteKey = path.resolve(pkgRoot, key);
browser[absoluteKey] = resolved;
if (!path.extname(key)) {
extensions.reduce((subBrowser, ext) => {
subBrowser[absoluteKey + ext] = subBrowser[key];
return subBrowser;
}, browser);
packageBrowserField:
useBrowserOverrides &&
typeof pkg.browser === 'object' &&
Object.keys(pkg.browser).reduce((browser, key) => {
let resolved = pkg.browser[key];
if (resolved && resolved[0] === '.') {
resolved = path.resolve(pkgRoot, resolved);
}
}
return browser;
}, {}),
/* eslint-disable no-param-reassign */
browser[key] = resolved;
if (key[0] === '.') {
const absoluteKey = path.resolve(pkgRoot, key);
browser[absoluteKey] = resolved;
if (!path.extname(key)) {
extensions.reduce((subBrowser, ext) => {
subBrowser[absoluteKey + ext] = subBrowser[key];
return subBrowser;
}, browser);
}
}
return browser;
}, {}),
packageInfo
};
const browserMap = internalPackageInfo.packageBrowserField;
if (useBrowserOverrides && typeof pkg.browser === 'object' && // eslint-disable-next-line no-prototype-builtins
browserMap.hasOwnProperty(pkg.main)) {
if (
useBrowserOverrides &&
typeof pkg.browser === 'object' &&
// eslint-disable-next-line no-prototype-builtins
browserMap.hasOwnProperty(pkg.main)
) {
packageInfo.resolvedEntryPoint = browserMap[pkg.main];

@@ -375,3 +213,2 @@ packageInfo.browserMappedMain = true;

const packageSideEffects = pkg.sideEffects;
if (typeof packageSideEffects === 'boolean') {

@@ -388,2 +225,3 @@ internalPackageInfo.hasModuleSideEffects = () => packageSideEffects;

}
function normalizeInput(input) {

@@ -394,9 +232,10 @@ if (Array.isArray(input)) {

return Object.values(input);
} // otherwise it's a string
}
// otherwise it's a string
return [input];
}
return [input];
} // Resolve module specifiers in order. Promise resolves to the first module that resolves
// 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) {

@@ -406,3 +245,3 @@ let promise = Promise.resolve();

for (let i = 0; i < importSpecifierList.length; i++) {
promise = promise.then(value => {
promise = promise.then((value) => {
// if we've already resolved to something, just return it.

@@ -413,7 +252,6 @@ if (value) {

return resolveId(importSpecifierList[i], resolveOptions).then(result => {
return resolveId(importSpecifierList[i], resolveOptions).then((result) => {
if (!resolveOptions.preserveSymlinks) {
result = fs.realpathSync(result);
}
return result;

@@ -425,3 +263,3 @@ });

// swallow MODULE_NOT_FOUND errors from all but the last resolution
promise = promise.catch(error => {
promise = promise.catch((error) => {
if (error.code !== 'MODULE_NOT_FOUND') {

@@ -437,7 +275,18 @@ throw error;

/* eslint-disable no-param-reassign, no-shadow, no-undefined */
const builtins = new Set(builtinList);
const ES6_BROWSER_EMPTY = '\0node-resolve:empty.js';
const nullFn = () => null;
const deepFreeze = (object) => {
Object.freeze(object);
for (const value of Object.values(object)) {
if (typeof value === 'object' && !Object.isFrozen(value)) {
deepFreeze(value);
}
}
return object;
};
const defaults = {

@@ -452,7 +301,6 @@ customResolveOptions: {},

const DEFAULTS = deepFreeze(deepMerge({}, defaults));
function nodeResolve(opts = {}) {
const options = Object.assign({}, defaults, opts);
const customResolveOptions = options.customResolveOptions,
extensions = options.extensions,
jail = options.jail;
const { customResolveOptions, extensions, jail } = options;
const warnings = [];

@@ -466,3 +314,3 @@ const packageInfoCache = new Map();

const rootDir = options.rootDir || process.cwd();
let dedupe = options.dedupe;
let { dedupe } = options;
let rollupOptions;

@@ -476,15 +324,17 @@

if (typeof dedupe !== 'function') {
dedupe = importee => options.dedupe.includes(importee) || options.dedupe.includes(getPackageName(importee));
dedupe = (importee) =>
options.dedupe.includes(importee) || options.dedupe.includes(getPackageName(importee));
}
const resolveOnly = options.resolveOnly.map(pattern => {
const resolveOnly = options.resolveOnly.map((pattern) => {
if (pattern instanceof RegExp) {
return pattern;
}
const normalized = pattern.replace(/[\\^$*+?.()|[\]{}]/g, '\\$&');
return new RegExp(`^${normalized}$`);
});
const browserMapCache = new Map();
let preserveSymlinks;
return {

@@ -496,17 +346,7 @@ name: 'node-resolve',

var _iterator = _createForOfIteratorHelper(warnings),
_step;
try {
for (_iterator.s(); !(_step = _iterator.n()).done;) {
const warning = _step.value;
this.warn(warning);
}
} catch (err) {
_iterator.e(err);
} finally {
_iterator.f();
for (const warning of warnings) {
this.warn(warning);
}
preserveSymlinks = options.preserveSymlinks;
({ preserveSymlinks } = options);
},

@@ -520,199 +360,184 @@

resolveId(importee, importer) {
var _this = this;
async resolveId(importee, importer) {
if (importee === ES6_BROWSER_EMPTY) {
return importee;
}
// ignore IDs with null character, these belong to other plugins
if (/\0/.test(importee)) return null;
return _asyncToGenerator(function* () {
if (importee === ES6_BROWSER_EMPTY) {
return importee;
} // ignore IDs with null character, these belong to other plugins
// strip hash and query params from import
const [withoutHash, hash] = importee.split('#');
const [importPath, params] = withoutHash.split('?');
const importSuffix = `${params ? `?${params}` : ''}${hash ? `#${hash}` : ''}`;
importee = importPath;
const basedir = !importer || dedupe(importee) ? rootDir : path.dirname(importer);
if (/\0/.test(importee)) return null; // strip hash and query params from import
const _importee$split = importee.split('#'),
_importee$split2 = _slicedToArray(_importee$split, 2),
withoutHash = _importee$split2[0],
hash = _importee$split2[1];
const _withoutHash$split = withoutHash.split('?'),
_withoutHash$split2 = _slicedToArray(_withoutHash$split, 2),
importPath = _withoutHash$split2[0],
params = _withoutHash$split2[1];
const importSuffix = `${params ? `?${params}` : ''}${hash ? `#${hash}` : ''}`;
importee = importPath;
const basedir = !importer || dedupe(importee) ? rootDir : path.dirname(importer); // https://github.com/defunctzombie/package-browser-field-spec
const browser = browserMapCache.get(importer);
if (useBrowserOverrides && browser) {
const resolvedImportee = path.resolve(basedir, importee);
if (browser[importee] === false || browser[resolvedImportee] === false) {
return ES6_BROWSER_EMPTY;
}
const browserImportee = browser[importee] || browser[resolvedImportee] || browser[`${resolvedImportee}.js`] || browser[`${resolvedImportee}.json`];
if (browserImportee) {
importee = browserImportee;
}
// https://github.com/defunctzombie/package-browser-field-spec
const browser = browserMapCache.get(importer);
if (useBrowserOverrides && browser) {
const resolvedImportee = path.resolve(basedir, importee);
if (browser[importee] === false || browser[resolvedImportee] === false) {
return ES6_BROWSER_EMPTY;
}
const browserImportee =
browser[importee] ||
browser[resolvedImportee] ||
browser[`${resolvedImportee}.js`] ||
browser[`${resolvedImportee}.json`];
if (browserImportee) {
importee = browserImportee;
}
}
const parts = importee.split(/[/\\]/);
let id = parts.shift();
let isRelativeImport = false;
const parts = importee.split(/[/\\]/);
let id = parts.shift();
let isRelativeImport = false;
if (id[0] === '@' && parts.length > 0) {
// scoped packages
id += `/${parts.shift()}`;
} else if (id[0] === '.') {
// an import relative to the parent dir of the importer
id = path.resolve(basedir, importee);
isRelativeImport = true;
}
if (id[0] === '@' && parts.length > 0) {
// scoped packages
id += `/${parts.shift()}`;
} else if (id[0] === '.') {
// an import relative to the parent dir of the importer
id = path.resolve(basedir, importee);
isRelativeImport = true;
}
if (!isRelativeImport && resolveOnly.length && !resolveOnly.some(pattern => pattern.test(id))) {
if (normalizeInput(rollupOptions.input).includes(importee)) {
return null;
}
return false;
if (
!isRelativeImport &&
resolveOnly.length &&
!resolveOnly.some((pattern) => pattern.test(id))
) {
if (normalizeInput(rollupOptions.input).includes(importee)) {
return null;
}
return false;
}
let hasModuleSideEffects = nullFn;
let hasPackageEntry = true;
let packageBrowserField = false;
let packageInfo;
let hasModuleSideEffects = nullFn;
let hasPackageEntry = true;
let packageBrowserField = false;
let packageInfo;
const filter = (pkg, pkgPath) => {
const info = getPackageInfo({
cache: packageInfoCache,
extensions,
pkg,
pkgPath,
mainFields,
preserveSymlinks,
useBrowserOverrides
});
packageInfo = info.packageInfo;
hasModuleSideEffects = info.hasModuleSideEffects;
hasPackageEntry = info.hasPackageEntry;
packageBrowserField = info.packageBrowserField;
return info.cachedPkg;
};
const filter = (pkg, pkgPath) => {
const info = getPackageInfo({
cache: packageInfoCache,
extensions,
pkg,
pkgPath,
mainFields,
preserveSymlinks,
useBrowserOverrides
});
let resolveOptions = {
basedir,
packageFilter: filter,
readFile: readCachedFile,
isFile: isFileCached,
isDirectory: isDirCached,
extensions
};
({ packageInfo, hasModuleSideEffects, hasPackageEntry, packageBrowserField } = info);
if (preserveSymlinks !== undefined) {
resolveOptions.preserveSymlinks = preserveSymlinks;
}
return info.cachedPkg;
};
const importSpecifierList = [];
let resolveOptions = {
basedir,
packageFilter: filter,
readFile: readCachedFile,
isFile: isFileCached,
isDirectory: isDirCached,
extensions
};
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}`);
}
if (preserveSymlinks !== undefined) {
resolveOptions.preserveSymlinks = preserveSymlinks;
}
const importeeIsBuiltin = builtins.has(importee);
const importSpecifierList = [];
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}/`);
} // TypeScript files may import '.js' to refer to either '.ts' or '.tsx'
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);
if (importer && importee.endsWith('.js')) {
for (var _i = 0, _arr = ['.ts', '.tsx']; _i < _arr.length; _i++) {
const ext = _arr[_i];
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}/`);
}
if (importer.endsWith(ext) && extensions.includes(ext)) {
importSpecifierList.push(importee.replace(/.js$/, ext));
}
// TypeScript files may import '.js' to refer to either '.ts' or '.tsx'
if (importer && importee.endsWith('.js')) {
for (const ext of ['.ts', '.tsx']) {
if (importer.endsWith(ext) && extensions.includes(ext)) {
importSpecifierList.push(importee.replace(/.js$/, ext));
}
}
}
importSpecifierList.push(importee);
resolveOptions = Object.assign(resolveOptions, customResolveOptions);
importSpecifierList.push(importee);
resolveOptions = Object.assign(resolveOptions, customResolveOptions);
try {
let resolved = yield resolveImportSpecifiers(importSpecifierList, resolveOptions);
try {
let resolved = await resolveImportSpecifiers(importSpecifierList, resolveOptions);
if (resolved && packageBrowserField) {
if (Object.prototype.hasOwnProperty.call(packageBrowserField, resolved)) {
if (!packageBrowserField[resolved]) {
browserMapCache.set(resolved, packageBrowserField);
return ES6_BROWSER_EMPTY;
}
resolved = packageBrowserField[resolved];
if (resolved && packageBrowserField) {
if (Object.prototype.hasOwnProperty.call(packageBrowserField, resolved)) {
if (!packageBrowserField[resolved]) {
browserMapCache.set(resolved, packageBrowserField);
return ES6_BROWSER_EMPTY;
}
browserMapCache.set(resolved, packageBrowserField);
resolved = packageBrowserField[resolved];
}
browserMapCache.set(resolved, packageBrowserField);
}
if (hasPackageEntry && !preserveSymlinks && resolved) {
const fileExists = yield exists(resolved);
if (fileExists) {
resolved = yield realpath(resolved);
}
if (hasPackageEntry && !preserveSymlinks && resolved) {
const fileExists = await exists(resolved);
if (fileExists) {
resolved = await realpath(resolved);
}
}
idToPackageInfo.set(resolved, packageInfo);
idToPackageInfo.set(resolved, packageInfo);
if (hasPackageEntry) {
if (builtins.has(resolved) && preferBuiltins && isPreferBuiltinsSet) {
return null;
} else if (importeeIsBuiltin && preferBuiltins) {
if (!isPreferBuiltinsSet) {
_this.warn(`preferring built-in module '${importee}' over local alternative at '${resolved}', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning`);
}
return null;
} else if (jail && resolved.indexOf(path.normalize(jail.trim(path.sep))) !== 0) {
return null;
if (hasPackageEntry) {
if (builtins.has(resolved) && preferBuiltins && isPreferBuiltinsSet) {
return null;
} else if (importeeIsBuiltin && preferBuiltins) {
if (!isPreferBuiltinsSet) {
this.warn(
`preferring built-in module '${importee}' over local alternative at '${resolved}', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning`
);
}
return null;
} else if (jail && resolved.indexOf(path.normalize(jail.trim(path.sep))) !== 0) {
return null;
}
}
if (resolved && options.modulesOnly) {
const code = yield readFile(resolved, 'utf-8');
if (isModule(code)) {
return {
id: `${resolved}${importSuffix}`,
moduleSideEffects: hasModuleSideEffects(resolved)
};
}
return null;
if (resolved && options.modulesOnly) {
const code = await readFile(resolved, 'utf-8');
if (isModule(code)) {
return {
id: `${resolved}${importSuffix}`,
moduleSideEffects: hasModuleSideEffects(resolved)
};
}
const result = {
id: `${resolved}${importSuffix}`,
moduleSideEffects: hasModuleSideEffects(resolved)
};
return result;
} catch (error) {
return null;
}
})();
const result = {
id: `${resolved}${importSuffix}`,
moduleSideEffects: hasModuleSideEffects(resolved)
};
return result;
} catch (error) {
return null;
}
},

@@ -724,3 +549,2 @@

}
return null;

@@ -732,3 +556,2 @@ },

}
};

@@ -735,0 +558,0 @@ }

import { dirname, resolve, extname, normalize, sep } from 'path';
import builtinList from 'builtin-modules';
import deepFreeze from 'deep-freeze';
import deepMerge from 'deepmerge';

@@ -11,149 +10,2 @@ import isModule from 'is-module';

function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
try {
var info = gen[key](arg);
var value = info.value;
} catch (error) {
reject(error);
return;
}
if (info.done) {
resolve(value);
} else {
Promise.resolve(value).then(_next, _throw);
}
}
function _asyncToGenerator(fn) {
return function () {
var self = this,
args = arguments;
return new Promise(function (resolve, reject) {
var gen = fn.apply(self, args);
function _next(value) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
}
function _throw(err) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
}
_next(undefined);
});
};
}
function _slicedToArray(arr, i) {
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
}
function _arrayWithHoles(arr) {
if (Array.isArray(arr)) return arr;
}
function _iterableToArrayLimit(arr, i) {
if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return;
var _arr = [];
var _n = true;
var _d = false;
var _e = undefined;
try {
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
_arr.push(_s.value);
if (i && _arr.length === i) break;
}
} catch (err) {
_d = true;
_e = err;
} finally {
try {
if (!_n && _i["return"] != null) _i["return"]();
} finally {
if (_d) throw _e;
}
}
return _arr;
}
function _unsupportedIterableToArray(o, minLen) {
if (!o) return;
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
var n = Object.prototype.toString.call(o).slice(8, -1);
if (n === "Object" && o.constructor) n = o.constructor.name;
if (n === "Map" || n === "Set") return Array.from(n);
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
}
function _arrayLikeToArray(arr, len) {
if (len == null || len > arr.length) len = arr.length;
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
return arr2;
}
function _nonIterableRest() {
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
function _createForOfIteratorHelper(o) {
if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) {
if (Array.isArray(o) || (o = _unsupportedIterableToArray(o))) {
var i = 0;
var F = function () {};
return {
s: F,
n: function () {
if (i >= o.length) return {
done: true
};
return {
done: false,
value: o[i++]
};
},
e: function (e) {
throw e;
},
f: F
};
}
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
var it,
normalCompletion = true,
didErr = false,
err;
return {
s: function () {
it = o[Symbol.iterator]();
},
n: function () {
var step = it.next();
normalCompletion = step.done;
return step;
},
e: function (e) {
didErr = true;
err = e;
},
f: function () {
try {
if (!normalCompletion && it.return != null) it.return();
} finally {
if (didErr) throw err;
}
}
};
}
const exists = promisify(fs.exists);

@@ -164,36 +16,31 @@ const readFile = promisify(fs.readFile);

const onError = error => {
const onError = (error) => {
if (error.code === 'ENOENT') {
return false;
}
throw error;
};
const makeCache = fn => {
const makeCache = (fn) => {
const cache = new Map();
const wrapped = /*#__PURE__*/function () {
var _ref = _asyncToGenerator(function* (param, done) {
if (cache.has(param) === false) {
cache.set(param, fn(param).catch(err => {
const wrapped = async (param, done) => {
if (cache.has(param) === false) {
cache.set(
param,
fn(param).catch((err) => {
cache.delete(param);
throw err;
}));
}
})
);
}
try {
const result = cache.get(param);
const value = yield result;
return done(null, value);
} catch (error) {
return done(error);
}
});
try {
const result = cache.get(param);
const value = await result;
return done(null, value);
} catch (error) {
return done(error);
}
};
return function wrapped(_x, _x2) {
return _ref.apply(this, arguments);
};
}();
wrapped.clear = () => cache.clear();

@@ -204,34 +51,25 @@

const isDirCached = makeCache( /*#__PURE__*/function () {
var _ref2 = _asyncToGenerator(function* (file) {
try {
const stats = yield stat(file);
return stats.isDirectory();
} catch (error) {
return onError(error);
}
});
const isDirCached = makeCache(async (file) => {
try {
const stats = await stat(file);
return stats.isDirectory();
} catch (error) {
return onError(error);
}
});
return function (_x3) {
return _ref2.apply(this, arguments);
};
}());
const isFileCached = makeCache( /*#__PURE__*/function () {
var _ref3 = _asyncToGenerator(function* (file) {
try {
const stats = yield stat(file);
return stats.isFile();
} catch (error) {
return onError(error);
}
});
const isFileCached = makeCache(async (file) => {
try {
const stats = await stat(file);
return stats.isFile();
} catch (error) {
return onError(error);
}
});
return function (_x4) {
return _ref3.apply(this, arguments);
};
}());
const readCachedFile = makeCache(readFile);
const resolveId = promisify(resolveModule); // returns the imported package name for bare module imports
const resolveId = promisify(resolveModule);
// returns the imported package name for bare module imports
function getPackageName(id) {

@@ -242,46 +80,40 @@ if (id.startsWith('.') || id.startsWith('/')) {

const split = id.split('/'); // @my-scope/my-package/foo.js -> @my-scope/my-package
const split = id.split('/');
// @my-scope/my-package/foo.js -> @my-scope/my-package
// @my-scope/my-package -> @my-scope/my-package
if (split[0][0] === '@') {
return `${split[0]}/${split[1]}`;
} // my-package/foo.js -> my-package
}
// my-package/foo.js -> my-package
// my-package -> my-package
return split[0];
}
function getMainFields(options) {
let mainFields;
if (options.mainFields) {
mainFields = options.mainFields;
({ mainFields } = options);
} else {
mainFields = ['module', 'main'];
}
if (options.browser && mainFields.indexOf('browser') === -1) {
return ['browser'].concat(mainFields);
}
if (!mainFields.length) {
throw new Error('Please ensure at least one `mainFields` value is specified');
}
return mainFields;
}
function getPackageInfo(options) {
const cache = options.cache,
extensions = options.extensions,
pkg = options.pkg,
mainFields = options.mainFields,
preserveSymlinks = options.preserveSymlinks,
useBrowserOverrides = options.useBrowserOverrides;
let pkgPath = options.pkgPath;
const { cache, extensions, pkg, mainFields, preserveSymlinks, useBrowserOverrides } = options;
let { pkgPath } = options;
if (cache.has(pkgPath)) {
return cache.get(pkgPath);
} // browserify/resolve doesn't realpath paths returned in its packageFilter callback
}
// browserify/resolve doesn't realpath paths returned in its packageFilter callback
if (!preserveSymlinks) {

@@ -292,13 +124,19 @@ pkgPath = realpathSync(pkgPath);

const pkgRoot = dirname(pkgPath);
const packageInfo = {
// copy as we are about to munge the `main` field of `pkg`.
packageJson: Object.assign({}, pkg),
// path to package.json file
packageJsonPath: pkgPath,
// directory containing the package.json
root: pkgRoot,
// which main field was used during resolution of this module (main, module, or browser)
resolvedMainField: 'main',
// whether the browser map was used to resolve the entry point to this module
browserMappedMain: false,
// the entry point of the module with respect to the selected main field and any

@@ -308,7 +146,6 @@ // relevant browser mappings.

};
let overriddenMain = false;
for (let i = 0; i < mainFields.length; i++) {
const field = mainFields[i];
if (typeof pkg[field] === 'string') {

@@ -326,33 +163,34 @@ pkg.main = pkg[field];

hasPackageEntry: overriddenMain !== false || mainFields.indexOf('main') !== -1,
packageBrowserField: useBrowserOverrides && typeof pkg.browser === 'object' && Object.keys(pkg.browser).reduce((browser, key) => {
let resolved = pkg.browser[key];
if (resolved && resolved[0] === '.') {
resolved = resolve(pkgRoot, resolved);
}
/* eslint-disable no-param-reassign */
browser[key] = resolved;
if (key[0] === '.') {
const absoluteKey = resolve(pkgRoot, key);
browser[absoluteKey] = resolved;
if (!extname(key)) {
extensions.reduce((subBrowser, ext) => {
subBrowser[absoluteKey + ext] = subBrowser[key];
return subBrowser;
}, browser);
packageBrowserField:
useBrowserOverrides &&
typeof pkg.browser === 'object' &&
Object.keys(pkg.browser).reduce((browser, key) => {
let resolved = pkg.browser[key];
if (resolved && resolved[0] === '.') {
resolved = resolve(pkgRoot, resolved);
}
}
return browser;
}, {}),
/* eslint-disable no-param-reassign */
browser[key] = resolved;
if (key[0] === '.') {
const absoluteKey = resolve(pkgRoot, key);
browser[absoluteKey] = resolved;
if (!extname(key)) {
extensions.reduce((subBrowser, ext) => {
subBrowser[absoluteKey + ext] = subBrowser[key];
return subBrowser;
}, browser);
}
}
return browser;
}, {}),
packageInfo
};
const browserMap = internalPackageInfo.packageBrowserField;
if (useBrowserOverrides && typeof pkg.browser === 'object' && // eslint-disable-next-line no-prototype-builtins
browserMap.hasOwnProperty(pkg.main)) {
if (
useBrowserOverrides &&
typeof pkg.browser === 'object' &&
// eslint-disable-next-line no-prototype-builtins
browserMap.hasOwnProperty(pkg.main)
) {
packageInfo.resolvedEntryPoint = browserMap[pkg.main];

@@ -367,3 +205,2 @@ packageInfo.browserMappedMain = true;

const packageSideEffects = pkg.sideEffects;
if (typeof packageSideEffects === 'boolean') {

@@ -380,2 +217,3 @@ internalPackageInfo.hasModuleSideEffects = () => packageSideEffects;

}
function normalizeInput(input) {

@@ -386,9 +224,10 @@ if (Array.isArray(input)) {

return Object.values(input);
} // otherwise it's a string
}
// otherwise it's a string
return [input];
}
return [input];
} // Resolve module specifiers in order. Promise resolves to the first module that resolves
// 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) {

@@ -398,3 +237,3 @@ let promise = Promise.resolve();

for (let i = 0; i < importSpecifierList.length; i++) {
promise = promise.then(value => {
promise = promise.then((value) => {
// if we've already resolved to something, just return it.

@@ -405,7 +244,6 @@ if (value) {

return resolveId(importSpecifierList[i], resolveOptions).then(result => {
return resolveId(importSpecifierList[i], resolveOptions).then((result) => {
if (!resolveOptions.preserveSymlinks) {
result = realpathSync(result);
}
return result;

@@ -417,3 +255,3 @@ });

// swallow MODULE_NOT_FOUND errors from all but the last resolution
promise = promise.catch(error => {
promise = promise.catch((error) => {
if (error.code !== 'MODULE_NOT_FOUND') {

@@ -429,7 +267,18 @@ throw error;

/* eslint-disable no-param-reassign, no-shadow, no-undefined */
const builtins = new Set(builtinList);
const ES6_BROWSER_EMPTY = '\0node-resolve:empty.js';
const nullFn = () => null;
const deepFreeze = (object) => {
Object.freeze(object);
for (const value of Object.values(object)) {
if (typeof value === 'object' && !Object.isFrozen(value)) {
deepFreeze(value);
}
}
return object;
};
const defaults = {

@@ -444,7 +293,6 @@ customResolveOptions: {},

const DEFAULTS = deepFreeze(deepMerge({}, defaults));
function nodeResolve(opts = {}) {
const options = Object.assign({}, defaults, opts);
const customResolveOptions = options.customResolveOptions,
extensions = options.extensions,
jail = options.jail;
const { customResolveOptions, extensions, jail } = options;
const warnings = [];

@@ -458,3 +306,3 @@ const packageInfoCache = new Map();

const rootDir = options.rootDir || process.cwd();
let dedupe = options.dedupe;
let { dedupe } = options;
let rollupOptions;

@@ -468,15 +316,17 @@

if (typeof dedupe !== 'function') {
dedupe = importee => options.dedupe.includes(importee) || options.dedupe.includes(getPackageName(importee));
dedupe = (importee) =>
options.dedupe.includes(importee) || options.dedupe.includes(getPackageName(importee));
}
const resolveOnly = options.resolveOnly.map(pattern => {
const resolveOnly = options.resolveOnly.map((pattern) => {
if (pattern instanceof RegExp) {
return pattern;
}
const normalized = pattern.replace(/[\\^$*+?.()|[\]{}]/g, '\\$&');
return new RegExp(`^${normalized}$`);
});
const browserMapCache = new Map();
let preserveSymlinks;
return {

@@ -488,17 +338,7 @@ name: 'node-resolve',

var _iterator = _createForOfIteratorHelper(warnings),
_step;
try {
for (_iterator.s(); !(_step = _iterator.n()).done;) {
const warning = _step.value;
this.warn(warning);
}
} catch (err) {
_iterator.e(err);
} finally {
_iterator.f();
for (const warning of warnings) {
this.warn(warning);
}
preserveSymlinks = options.preserveSymlinks;
({ preserveSymlinks } = options);
},

@@ -512,199 +352,184 @@

resolveId(importee, importer) {
var _this = this;
async resolveId(importee, importer) {
if (importee === ES6_BROWSER_EMPTY) {
return importee;
}
// ignore IDs with null character, these belong to other plugins
if (/\0/.test(importee)) return null;
return _asyncToGenerator(function* () {
if (importee === ES6_BROWSER_EMPTY) {
return importee;
} // ignore IDs with null character, these belong to other plugins
// strip hash and query params from import
const [withoutHash, hash] = importee.split('#');
const [importPath, params] = withoutHash.split('?');
const importSuffix = `${params ? `?${params}` : ''}${hash ? `#${hash}` : ''}`;
importee = importPath;
const basedir = !importer || dedupe(importee) ? rootDir : dirname(importer);
if (/\0/.test(importee)) return null; // strip hash and query params from import
const _importee$split = importee.split('#'),
_importee$split2 = _slicedToArray(_importee$split, 2),
withoutHash = _importee$split2[0],
hash = _importee$split2[1];
const _withoutHash$split = withoutHash.split('?'),
_withoutHash$split2 = _slicedToArray(_withoutHash$split, 2),
importPath = _withoutHash$split2[0],
params = _withoutHash$split2[1];
const importSuffix = `${params ? `?${params}` : ''}${hash ? `#${hash}` : ''}`;
importee = importPath;
const basedir = !importer || dedupe(importee) ? rootDir : dirname(importer); // https://github.com/defunctzombie/package-browser-field-spec
const browser = browserMapCache.get(importer);
if (useBrowserOverrides && browser) {
const resolvedImportee = resolve(basedir, importee);
if (browser[importee] === false || browser[resolvedImportee] === false) {
return ES6_BROWSER_EMPTY;
}
const browserImportee = browser[importee] || browser[resolvedImportee] || browser[`${resolvedImportee}.js`] || browser[`${resolvedImportee}.json`];
if (browserImportee) {
importee = browserImportee;
}
// https://github.com/defunctzombie/package-browser-field-spec
const browser = browserMapCache.get(importer);
if (useBrowserOverrides && browser) {
const resolvedImportee = resolve(basedir, importee);
if (browser[importee] === false || browser[resolvedImportee] === false) {
return ES6_BROWSER_EMPTY;
}
const browserImportee =
browser[importee] ||
browser[resolvedImportee] ||
browser[`${resolvedImportee}.js`] ||
browser[`${resolvedImportee}.json`];
if (browserImportee) {
importee = browserImportee;
}
}
const parts = importee.split(/[/\\]/);
let id = parts.shift();
let isRelativeImport = false;
const parts = importee.split(/[/\\]/);
let id = parts.shift();
let isRelativeImport = false;
if (id[0] === '@' && parts.length > 0) {
// scoped packages
id += `/${parts.shift()}`;
} else if (id[0] === '.') {
// an import relative to the parent dir of the importer
id = resolve(basedir, importee);
isRelativeImport = true;
}
if (id[0] === '@' && parts.length > 0) {
// scoped packages
id += `/${parts.shift()}`;
} else if (id[0] === '.') {
// an import relative to the parent dir of the importer
id = resolve(basedir, importee);
isRelativeImport = true;
}
if (!isRelativeImport && resolveOnly.length && !resolveOnly.some(pattern => pattern.test(id))) {
if (normalizeInput(rollupOptions.input).includes(importee)) {
return null;
}
return false;
if (
!isRelativeImport &&
resolveOnly.length &&
!resolveOnly.some((pattern) => pattern.test(id))
) {
if (normalizeInput(rollupOptions.input).includes(importee)) {
return null;
}
return false;
}
let hasModuleSideEffects = nullFn;
let hasPackageEntry = true;
let packageBrowserField = false;
let packageInfo;
let hasModuleSideEffects = nullFn;
let hasPackageEntry = true;
let packageBrowserField = false;
let packageInfo;
const filter = (pkg, pkgPath) => {
const info = getPackageInfo({
cache: packageInfoCache,
extensions,
pkg,
pkgPath,
mainFields,
preserveSymlinks,
useBrowserOverrides
});
packageInfo = info.packageInfo;
hasModuleSideEffects = info.hasModuleSideEffects;
hasPackageEntry = info.hasPackageEntry;
packageBrowserField = info.packageBrowserField;
return info.cachedPkg;
};
const filter = (pkg, pkgPath) => {
const info = getPackageInfo({
cache: packageInfoCache,
extensions,
pkg,
pkgPath,
mainFields,
preserveSymlinks,
useBrowserOverrides
});
let resolveOptions = {
basedir,
packageFilter: filter,
readFile: readCachedFile,
isFile: isFileCached,
isDirectory: isDirCached,
extensions
};
({ packageInfo, hasModuleSideEffects, hasPackageEntry, packageBrowserField } = info);
if (preserveSymlinks !== undefined) {
resolveOptions.preserveSymlinks = preserveSymlinks;
}
return info.cachedPkg;
};
const importSpecifierList = [];
let resolveOptions = {
basedir,
packageFilter: filter,
readFile: readCachedFile,
isFile: isFileCached,
isDirectory: isDirCached,
extensions
};
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}`);
}
if (preserveSymlinks !== undefined) {
resolveOptions.preserveSymlinks = preserveSymlinks;
}
const importeeIsBuiltin = builtins.has(importee);
const importSpecifierList = [];
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}/`);
} // TypeScript files may import '.js' to refer to either '.ts' or '.tsx'
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);
if (importer && importee.endsWith('.js')) {
for (var _i = 0, _arr = ['.ts', '.tsx']; _i < _arr.length; _i++) {
const ext = _arr[_i];
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}/`);
}
if (importer.endsWith(ext) && extensions.includes(ext)) {
importSpecifierList.push(importee.replace(/.js$/, ext));
}
// TypeScript files may import '.js' to refer to either '.ts' or '.tsx'
if (importer && importee.endsWith('.js')) {
for (const ext of ['.ts', '.tsx']) {
if (importer.endsWith(ext) && extensions.includes(ext)) {
importSpecifierList.push(importee.replace(/.js$/, ext));
}
}
}
importSpecifierList.push(importee);
resolveOptions = Object.assign(resolveOptions, customResolveOptions);
importSpecifierList.push(importee);
resolveOptions = Object.assign(resolveOptions, customResolveOptions);
try {
let resolved = yield resolveImportSpecifiers(importSpecifierList, resolveOptions);
try {
let resolved = await resolveImportSpecifiers(importSpecifierList, resolveOptions);
if (resolved && packageBrowserField) {
if (Object.prototype.hasOwnProperty.call(packageBrowserField, resolved)) {
if (!packageBrowserField[resolved]) {
browserMapCache.set(resolved, packageBrowserField);
return ES6_BROWSER_EMPTY;
}
resolved = packageBrowserField[resolved];
if (resolved && packageBrowserField) {
if (Object.prototype.hasOwnProperty.call(packageBrowserField, resolved)) {
if (!packageBrowserField[resolved]) {
browserMapCache.set(resolved, packageBrowserField);
return ES6_BROWSER_EMPTY;
}
browserMapCache.set(resolved, packageBrowserField);
resolved = packageBrowserField[resolved];
}
browserMapCache.set(resolved, packageBrowserField);
}
if (hasPackageEntry && !preserveSymlinks && resolved) {
const fileExists = yield exists(resolved);
if (fileExists) {
resolved = yield realpath(resolved);
}
if (hasPackageEntry && !preserveSymlinks && resolved) {
const fileExists = await exists(resolved);
if (fileExists) {
resolved = await realpath(resolved);
}
}
idToPackageInfo.set(resolved, packageInfo);
idToPackageInfo.set(resolved, packageInfo);
if (hasPackageEntry) {
if (builtins.has(resolved) && preferBuiltins && isPreferBuiltinsSet) {
return null;
} else if (importeeIsBuiltin && preferBuiltins) {
if (!isPreferBuiltinsSet) {
_this.warn(`preferring built-in module '${importee}' over local alternative at '${resolved}', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning`);
}
return null;
} else if (jail && resolved.indexOf(normalize(jail.trim(sep))) !== 0) {
return null;
if (hasPackageEntry) {
if (builtins.has(resolved) && preferBuiltins && isPreferBuiltinsSet) {
return null;
} else if (importeeIsBuiltin && preferBuiltins) {
if (!isPreferBuiltinsSet) {
this.warn(
`preferring built-in module '${importee}' over local alternative at '${resolved}', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning`
);
}
return null;
} else if (jail && resolved.indexOf(normalize(jail.trim(sep))) !== 0) {
return null;
}
}
if (resolved && options.modulesOnly) {
const code = yield readFile(resolved, 'utf-8');
if (isModule(code)) {
return {
id: `${resolved}${importSuffix}`,
moduleSideEffects: hasModuleSideEffects(resolved)
};
}
return null;
if (resolved && options.modulesOnly) {
const code = await readFile(resolved, 'utf-8');
if (isModule(code)) {
return {
id: `${resolved}${importSuffix}`,
moduleSideEffects: hasModuleSideEffects(resolved)
};
}
const result = {
id: `${resolved}${importSuffix}`,
moduleSideEffects: hasModuleSideEffects(resolved)
};
return result;
} catch (error) {
return null;
}
})();
const result = {
id: `${resolved}${importSuffix}`,
moduleSideEffects: hasModuleSideEffects(resolved)
};
return result;
} catch (error) {
return null;
}
},

@@ -716,3 +541,2 @@

}
return null;

@@ -724,3 +548,2 @@ },

}
};

@@ -727,0 +550,0 @@ }

{
"name": "@rollup/plugin-node-resolve",
"version": "8.4.0",
"version": "9.0.0",
"publishConfig": {

@@ -14,4 +14,5 @@ "access": "public"

"main": "./dist/cjs/index.js",
"module": "./dist/es/index.js",
"engines": {
"node": ">= 8.0.0"
"node": ">= 10.0.0"
},

@@ -25,3 +26,3 @@ "scripts": {

"lint": "pnpm run lint:js && pnpm run lint:docs && pnpm run lint:package",
"lint:docs": "prettier --single-quote --write README.md",
"lint:docs": "prettier --single-quote --arrow-parens avoid --trailing-comma none --write README.md",
"lint:js": "eslint --fix --cache src test types --ext .js,.ts",

@@ -56,3 +57,2 @@ "lint:package": "prettier --write package.json --plugin=prettier-plugin-package",

"builtin-modules": "^3.1.0",
"deep-freeze": "^0.0.1",
"deepmerge": "^4.2.2",

@@ -63,14 +63,17 @@ "is-module": "^1.0.0",

"devDependencies": {
"@babel/core": "^7.10.4",
"@babel/plugin-transform-typescript": "^7.10.4",
"@babel/preset-env": "^7.10.4",
"@rollup/plugin-babel": "^5.0.4",
"@rollup/plugin-commonjs": "^13.0.0",
"@babel/core": "^7.10.5",
"@babel/plugin-transform-typescript": "^7.10.5",
"@rollup/plugin-babel": "^5.1.0",
"@rollup/plugin-commonjs": "^14.0.0",
"@rollup/plugin-json": "^4.1.0",
"es5-ext": "^0.10.53",
"rollup": "^2.12.0",
"rollup": "^2.23.0",
"source-map": "^0.7.3",
"string-capitalize": "^1.0.1"
},
"types": "types/index.d.ts",
"ava": {
"babel": {
"compileEnhancements": false
},
"files": [

@@ -87,5 +90,3 @@ "!**/fixtures/**",

},
"module": "./dist/es/index.js",
"type": "commonjs",
"types": "types/index.d.ts"
"type": "commonjs"
}
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