Socket
Socket
Sign inDemoInstall

@rollup/plugin-node-resolve

Package Overview
Dependencies
Maintainers
4
Versions
45
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 13.0.3 to 13.0.4

8

CHANGELOG.md
# @rollup/plugin-node-resolve ChangeLog
## v13.0.4
_2021-07-24_
### Bugfixes
- fix
## v13.0.3

@@ -4,0 +12,0 @@

273

dist/cjs/index.js

@@ -38,2 +38,6 @@ 'use strict';

async function resolveSymlink(path) {
return (await fileExists(path)) ? realpath(path) : path;
}
const onError = (error) => {

@@ -316,4 +320,4 @@ if (error.code === 'ENOENT') {

class InvalidModuleSpecifierError extends ResolveError {
constructor(context, internal) {
super(createErrorMsg(context, internal));
constructor(context, internal, reason) {
super(createErrorMsg(context, reason, internal));
}

@@ -545,3 +549,3 @@ }

if (importSpecifier === '#' || importSpecifier.startsWith('#/')) {
throw new InvalidModuleSpecifierError(context, 'Invalid import specifier.');
throw new InvalidModuleSpecifierError(context, true, 'Invalid import specifier.');
}

@@ -577,7 +581,4 @@

async function resolveId({
importer,
async function resolveIdClassic({
importSpecifier,
exportConditions,
warn,
packageInfoCache,

@@ -629,4 +630,34 @@ extensions,

let location;
try {
location = await resolveImportPath(importSpecifier, resolveOptions);
} catch (error) {
if (error.code !== 'MODULE_NOT_FOUND') {
throw error;
}
return null;
}
const pkgName = getPackageName(importSpecifier);
return {
location: preserveSymlinks ? location : await resolveSymlink(location),
hasModuleSideEffects,
hasPackageEntry,
packageBrowserField,
packageInfo
};
}
async function resolveWithExportMap({
importer,
importSpecifier,
exportConditions,
packageInfoCache,
extensions,
mainFields,
preserveSymlinks,
useBrowserOverrides,
baseDir,
moduleDirectories,
rootDir,
ignoreSideEffectsForRoot
}) {
if (importSpecifier.startsWith('#')) {

@@ -639,8 +670,5 @@ // this is a package internal import, resolve using package imports field

conditions: exportConditions,
resolveId(id, parent) {
return resolveId({
resolveId(id /* , parent*/) {
return resolveIdClassic({
importSpecifier: id,
importer: parent,
exportConditions,
warn,
packageInfoCache,

@@ -656,33 +684,79 @@ extensions,

});
location = url.fileURLToPath(resolveResult);
} else if (pkgName) {
const location = url.fileURLToPath(resolveResult);
return {
location: preserveSymlinks ? location : await resolveSymlink(location),
hasModuleSideEffects: () => null,
hasPackageEntry: true,
packageBrowserField: false,
// eslint-disable-next-line no-undefined
packageInfo: undefined
};
}
const pkgName = getPackageName(importSpecifier);
if (pkgName) {
// it's a bare import, find the package.json and resolve using package exports if available
let hasModuleSideEffects = () => null;
let hasPackageEntry = true;
let packageBrowserField = false;
let packageInfo;
const filter = (pkg, pkgPath) => {
const info = getPackageInfo({
cache: packageInfoCache,
extensions,
pkg,
pkgPath,
mainFields,
preserveSymlinks,
useBrowserOverrides,
rootDir,
ignoreSideEffectsForRoot
});
({ packageInfo, hasModuleSideEffects, hasPackageEntry, packageBrowserField } = info);
return info.cachedPkg;
};
const resolveOptions = {
basedir: baseDir,
readFile: readCachedFile,
isFile: isFileCached,
isDirectory: isDirCached,
extensions,
includeCoreModules: false,
moduleDirectory: moduleDirectories,
preserveSymlinks,
packageFilter: filter
};
const result = await getPackageJson(importer, pkgName, resolveOptions, moduleDirectories);
if (result && result.pkgJson.exports) {
const { pkgJson, pkgJsonPath, pkgPath } = result;
try {
const subpath =
pkgName === importSpecifier ? '.' : `.${importSpecifier.substring(pkgName.length)}`;
const pkgURL = url.pathToFileURL(`${pkgPath}/`);
const { pkgJson, pkgJsonPath } = result;
const subpath =
pkgName === importSpecifier ? '.' : `.${importSpecifier.substring(pkgName.length)}`;
const pkgDr = pkgJsonPath.replace('package.json', '');
const pkgURL = url.pathToFileURL(pkgDr);
const context = {
importer,
importSpecifier,
moduleDirs: moduleDirectories,
pkgURL,
pkgJsonPath,
conditions: exportConditions
const context = {
importer,
importSpecifier,
moduleDirs: moduleDirectories,
pkgURL,
pkgJsonPath,
conditions: exportConditions
};
const resolvedPackageExport = await resolvePackageExports(context, subpath, pkgJson.exports);
const location = url.fileURLToPath(resolvedPackageExport);
if (location) {
return {
location: preserveSymlinks ? location : await resolveSymlink(location),
hasModuleSideEffects,
hasPackageEntry,
packageBrowserField,
packageInfo
};
const resolvedPackageExport = await resolvePackageExports(
context,
subpath,
pkgJson.exports
);
location = url.fileURLToPath(resolvedPackageExport);
} catch (error) {
if (error instanceof ResolveError) {
return error;
}
throw error;
}

@@ -692,32 +766,6 @@ }

if (!location) {
// package has no imports or exports, use classic node resolve
try {
location = await resolveImportPath(importSpecifier, resolveOptions);
} catch (error) {
if (error.code !== 'MODULE_NOT_FOUND') {
throw error;
}
return null;
}
}
if (!preserveSymlinks) {
if (await fileExists(location)) {
location = await realpath(location);
}
}
return {
location,
hasModuleSideEffects,
hasPackageEntry,
packageBrowserField,
packageInfo
};
return null;
}
// 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.
async function resolveImportSpecifiers({
async function resolveWithClassic({
importer,

@@ -737,7 +785,5 @@ importSpecifierList,

}) {
let lastResolveError;
for (let i = 0; i < importSpecifierList.length; i++) {
// eslint-disable-next-line no-await-in-loop
const result = await resolveId({
const result = await resolveIdClassic({
importer,

@@ -758,5 +804,3 @@ importSpecifier: importSpecifierList[i],

if (result instanceof ResolveError) {
lastResolveError = result;
} else if (result) {
if (result) {
return result;

@@ -766,9 +810,66 @@ }

if (lastResolveError) {
// only log the last failed resolve error
warn(lastResolveError);
}
return null;
}
// Resolves to the module if found or `null`.
// The first import specificer will first be attempted with the exports algorithm.
// If this is unsuccesful because export maps are not being used, then all of `importSpecifierList`
// will be tried with the classic resolution algorithm
async function resolveImportSpecifiers({
importer,
importSpecifierList,
exportConditions,
warn,
packageInfoCache,
extensions,
mainFields,
preserveSymlinks,
useBrowserOverrides,
baseDir,
moduleDirectories,
rootDir,
ignoreSideEffectsForRoot
}) {
try {
const exportMapRes = await resolveWithExportMap({
importer,
importSpecifier: importSpecifierList[0],
exportConditions,
packageInfoCache,
extensions,
mainFields,
preserveSymlinks,
useBrowserOverrides,
baseDir,
moduleDirectories,
rootDir,
ignoreSideEffectsForRoot
});
if (exportMapRes) return exportMapRes;
} catch (error) {
if (error instanceof ResolveError) {
warn(error);
return null;
}
throw error;
}
// package has no imports or exports, use classic node resolve
return resolveWithClassic({
importer,
importSpecifierList,
exportConditions,
warn,
packageInfoCache,
extensions,
mainFields,
preserveSymlinks,
useBrowserOverrides,
baseDir,
moduleDirectories,
rootDir,
ignoreSideEffectsForRoot
});
}
function handleDeprecatedOptions(opts) {

@@ -933,3 +1034,3 @@ const warnings = [];

const importSpecifierList = [];
const importSpecifierList = [importee];

@@ -941,19 +1042,6 @@ if (importer === undefined && !importee[0].match(/^\.?\.?\//)) {

// 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.
// resolve it.
importSpecifierList.push(`./${importee}`);
}
const importeeIsBuiltin = builtins.has(importee);
if (importeeIsBuiltin) {
// 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'

@@ -968,4 +1056,2 @@ if (importer && importee.endsWith('.js')) {

importSpecifierList.push(importee);
const warn = (...args) => context.warn(...args);

@@ -995,2 +1081,3 @@ const isRequire =

const importeeIsBuiltin = builtins.has(importee);
const resolved =

@@ -997,0 +1084,0 @@ importeeIsBuiltin && preferBuiltins

@@ -25,2 +25,6 @@ import path, { dirname, resolve, extname, normalize, sep } from 'path';

async function resolveSymlink(path) {
return (await fileExists(path)) ? realpath(path) : path;
}
const onError = (error) => {

@@ -303,4 +307,4 @@ if (error.code === 'ENOENT') {

class InvalidModuleSpecifierError extends ResolveError {
constructor(context, internal) {
super(createErrorMsg(context, internal));
constructor(context, internal, reason) {
super(createErrorMsg(context, reason, internal));
}

@@ -532,3 +536,3 @@ }

if (importSpecifier === '#' || importSpecifier.startsWith('#/')) {
throw new InvalidModuleSpecifierError(context, 'Invalid import specifier.');
throw new InvalidModuleSpecifierError(context, true, 'Invalid import specifier.');
}

@@ -564,7 +568,4 @@

async function resolveId({
importer,
async function resolveIdClassic({
importSpecifier,
exportConditions,
warn,
packageInfoCache,

@@ -616,4 +617,34 @@ extensions,

let location;
try {
location = await resolveImportPath(importSpecifier, resolveOptions);
} catch (error) {
if (error.code !== 'MODULE_NOT_FOUND') {
throw error;
}
return null;
}
const pkgName = getPackageName(importSpecifier);
return {
location: preserveSymlinks ? location : await resolveSymlink(location),
hasModuleSideEffects,
hasPackageEntry,
packageBrowserField,
packageInfo
};
}
async function resolveWithExportMap({
importer,
importSpecifier,
exportConditions,
packageInfoCache,
extensions,
mainFields,
preserveSymlinks,
useBrowserOverrides,
baseDir,
moduleDirectories,
rootDir,
ignoreSideEffectsForRoot
}) {
if (importSpecifier.startsWith('#')) {

@@ -626,8 +657,5 @@ // this is a package internal import, resolve using package imports field

conditions: exportConditions,
resolveId(id, parent) {
return resolveId({
resolveId(id /* , parent*/) {
return resolveIdClassic({
importSpecifier: id,
importer: parent,
exportConditions,
warn,
packageInfoCache,

@@ -643,33 +671,79 @@ extensions,

});
location = fileURLToPath(resolveResult);
} else if (pkgName) {
const location = fileURLToPath(resolveResult);
return {
location: preserveSymlinks ? location : await resolveSymlink(location),
hasModuleSideEffects: () => null,
hasPackageEntry: true,
packageBrowserField: false,
// eslint-disable-next-line no-undefined
packageInfo: undefined
};
}
const pkgName = getPackageName(importSpecifier);
if (pkgName) {
// it's a bare import, find the package.json and resolve using package exports if available
let hasModuleSideEffects = () => null;
let hasPackageEntry = true;
let packageBrowserField = false;
let packageInfo;
const filter = (pkg, pkgPath) => {
const info = getPackageInfo({
cache: packageInfoCache,
extensions,
pkg,
pkgPath,
mainFields,
preserveSymlinks,
useBrowserOverrides,
rootDir,
ignoreSideEffectsForRoot
});
({ packageInfo, hasModuleSideEffects, hasPackageEntry, packageBrowserField } = info);
return info.cachedPkg;
};
const resolveOptions = {
basedir: baseDir,
readFile: readCachedFile,
isFile: isFileCached,
isDirectory: isDirCached,
extensions,
includeCoreModules: false,
moduleDirectory: moduleDirectories,
preserveSymlinks,
packageFilter: filter
};
const result = await getPackageJson(importer, pkgName, resolveOptions, moduleDirectories);
if (result && result.pkgJson.exports) {
const { pkgJson, pkgJsonPath, pkgPath } = result;
try {
const subpath =
pkgName === importSpecifier ? '.' : `.${importSpecifier.substring(pkgName.length)}`;
const pkgURL = pathToFileURL(`${pkgPath}/`);
const { pkgJson, pkgJsonPath } = result;
const subpath =
pkgName === importSpecifier ? '.' : `.${importSpecifier.substring(pkgName.length)}`;
const pkgDr = pkgJsonPath.replace('package.json', '');
const pkgURL = pathToFileURL(pkgDr);
const context = {
importer,
importSpecifier,
moduleDirs: moduleDirectories,
pkgURL,
pkgJsonPath,
conditions: exportConditions
const context = {
importer,
importSpecifier,
moduleDirs: moduleDirectories,
pkgURL,
pkgJsonPath,
conditions: exportConditions
};
const resolvedPackageExport = await resolvePackageExports(context, subpath, pkgJson.exports);
const location = fileURLToPath(resolvedPackageExport);
if (location) {
return {
location: preserveSymlinks ? location : await resolveSymlink(location),
hasModuleSideEffects,
hasPackageEntry,
packageBrowserField,
packageInfo
};
const resolvedPackageExport = await resolvePackageExports(
context,
subpath,
pkgJson.exports
);
location = fileURLToPath(resolvedPackageExport);
} catch (error) {
if (error instanceof ResolveError) {
return error;
}
throw error;
}

@@ -679,32 +753,6 @@ }

if (!location) {
// package has no imports or exports, use classic node resolve
try {
location = await resolveImportPath(importSpecifier, resolveOptions);
} catch (error) {
if (error.code !== 'MODULE_NOT_FOUND') {
throw error;
}
return null;
}
}
if (!preserveSymlinks) {
if (await fileExists(location)) {
location = await realpath(location);
}
}
return {
location,
hasModuleSideEffects,
hasPackageEntry,
packageBrowserField,
packageInfo
};
return null;
}
// 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.
async function resolveImportSpecifiers({
async function resolveWithClassic({
importer,

@@ -724,7 +772,5 @@ importSpecifierList,

}) {
let lastResolveError;
for (let i = 0; i < importSpecifierList.length; i++) {
// eslint-disable-next-line no-await-in-loop
const result = await resolveId({
const result = await resolveIdClassic({
importer,

@@ -745,5 +791,3 @@ importSpecifier: importSpecifierList[i],

if (result instanceof ResolveError) {
lastResolveError = result;
} else if (result) {
if (result) {
return result;

@@ -753,9 +797,66 @@ }

if (lastResolveError) {
// only log the last failed resolve error
warn(lastResolveError);
}
return null;
}
// Resolves to the module if found or `null`.
// The first import specificer will first be attempted with the exports algorithm.
// If this is unsuccesful because export maps are not being used, then all of `importSpecifierList`
// will be tried with the classic resolution algorithm
async function resolveImportSpecifiers({
importer,
importSpecifierList,
exportConditions,
warn,
packageInfoCache,
extensions,
mainFields,
preserveSymlinks,
useBrowserOverrides,
baseDir,
moduleDirectories,
rootDir,
ignoreSideEffectsForRoot
}) {
try {
const exportMapRes = await resolveWithExportMap({
importer,
importSpecifier: importSpecifierList[0],
exportConditions,
packageInfoCache,
extensions,
mainFields,
preserveSymlinks,
useBrowserOverrides,
baseDir,
moduleDirectories,
rootDir,
ignoreSideEffectsForRoot
});
if (exportMapRes) return exportMapRes;
} catch (error) {
if (error instanceof ResolveError) {
warn(error);
return null;
}
throw error;
}
// package has no imports or exports, use classic node resolve
return resolveWithClassic({
importer,
importSpecifierList,
exportConditions,
warn,
packageInfoCache,
extensions,
mainFields,
preserveSymlinks,
useBrowserOverrides,
baseDir,
moduleDirectories,
rootDir,
ignoreSideEffectsForRoot
});
}
function handleDeprecatedOptions(opts) {

@@ -920,3 +1021,3 @@ const warnings = [];

const importSpecifierList = [];
const importSpecifierList = [importee];

@@ -928,19 +1029,6 @@ if (importer === undefined && !importee[0].match(/^\.?\.?\//)) {

// 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.
// resolve it.
importSpecifierList.push(`./${importee}`);
}
const importeeIsBuiltin = builtins.has(importee);
if (importeeIsBuiltin) {
// 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'

@@ -955,4 +1043,2 @@ if (importer && importee.endsWith('.js')) {

importSpecifierList.push(importee);
const warn = (...args) => context.warn(...args);

@@ -982,2 +1068,3 @@ const isRequire =

const importeeIsBuiltin = builtins.has(importee);
const resolved =

@@ -984,0 +1071,0 @@ importeeIsBuiltin && preferBuiltins

{
"name": "@rollup/plugin-node-resolve",
"version": "13.0.3",
"version": "13.0.4",
"publishConfig": {

@@ -5,0 +5,0 @@ "access": "public"

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