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 11.0.0 to 11.0.1

13

CHANGELOG.md
# @rollup/plugin-node-resolve ChangeLog
## v11.0.1
_2020-12-14_
### Bugfixes
- fix: export map specificity (#675)
- fix: add missing type import (#668)
### Updates
- docs: corrected word "yse" to "use" (#723)
## v11.0.0

@@ -4,0 +17,0 @@

88

dist/cjs/index.js

@@ -235,7 +235,18 @@ 'use strict';

const pathNotFoundError = (subPath, pkgPath) =>
new Error(`Package subpath '${subPath}' is not defined by "exports" in ${pkgPath}`);
const pathNotFoundError = (importPath, importer, subPath, pkgPath) =>
new Error(
`Could not resolve import "${importPath}" in "${importer}".` +
` Package subpath "${subPath}" is not defined by "exports" in ${pkgPath}`
);
function findExportKeyMatch(exportMap, subPath) {
for (const key of Object.keys(exportMap)) {
if (subPath in exportMap) {
return subPath;
}
const matchKeys = Object.keys(exportMap)
.filter((key) => key.endsWith('/') || key.endsWith('*'))
.sort((a, b) => b.length - a.length);
for (const key of matchKeys) {
if (key.endsWith('*')) {

@@ -262,3 +273,3 @@ // star match: "./foo/*": "./foo/*.js"

function mapSubPath(pkgJsonPath, subPath, key, value) {
function mapSubPath({ importPath, importer, pkgJsonPath, subPath, key, value }) {
if (typeof value === 'string') {

@@ -286,8 +297,16 @@ if (typeof key === 'string' && key.endsWith('*')) {

throw pathNotFoundError(subPath, pkgJsonPath);
throw pathNotFoundError(importPath, importer, subPath, pkgJsonPath);
}
function findEntrypoint(pkgJsonPath, subPath, exportMap, conditions, key) {
function findEntrypoint({
importPath,
importer,
pkgJsonPath,
subPath,
exportMap,
conditions,
key
}) {
if (typeof exportMap !== 'object') {
return mapSubPath(pkgJsonPath, subPath, key, exportMap);
return mapSubPath({ importPath, importer, pkgJsonPath, subPath, key, value: exportMap });
}

@@ -298,3 +317,11 @@

if (conditions.includes(condition)) {
const mappedSubPath = findEntrypoint(pkgJsonPath, subPath, subExportMap, conditions, key);
const mappedSubPath = findEntrypoint({
importPath,
importer,
pkgJsonPath,
subPath,
exportMap: subExportMap,
conditions,
key
});
if (mappedSubPath) {

@@ -305,6 +332,13 @@ return mappedSubPath;

}
throw pathNotFoundError(subPath, pkgJsonPath);
throw pathNotFoundError(importer, subPath, pkgJsonPath);
}
function findEntrypointTopLevel(pkgJsonPath, subPath, exportMap, conditions) {
function findEntrypointTopLevel({
importPath,
importer,
pkgJsonPath,
subPath,
exportMap,
conditions
}) {
if (typeof exportMap !== 'object') {

@@ -314,5 +348,5 @@ // the export map shorthand, for example { exports: "./index.js" }

// shorthand only supports a main entrypoint
throw pathNotFoundError(subPath, pkgJsonPath);
throw pathNotFoundError(importPath, importer, subPath, pkgJsonPath);
}
return mapSubPath(pkgJsonPath, subPath, null, exportMap);
return mapSubPath({ importPath, importer, pkgJsonPath, subPath, key: null, value: exportMap });
}

@@ -340,3 +374,3 @@

// package with top level conditions means it only supports a main entrypoint
throw pathNotFoundError(subPath, pkgJsonPath);
throw pathNotFoundError(importPath, importer, subPath, pkgJsonPath);
}

@@ -348,3 +382,3 @@ exportMapForSubPath = exportMap;

if (!key) {
throw pathNotFoundError(subPath, pkgJsonPath);
throw pathNotFoundError(importPath, importer, subPath, pkgJsonPath);
}

@@ -354,6 +388,15 @@ exportMapForSubPath = exportMap[key];

return findEntrypoint(pkgJsonPath, subPath, exportMapForSubPath, conditions, key);
return findEntrypoint({
importPath,
importer,
pkgJsonPath,
subPath,
exportMap: exportMapForSubPath,
conditions,
key
});
}
async function resolveId({
importer,
importPath,

@@ -420,8 +463,10 @@ exportConditions,

pkgName === importPath ? '.' : `.${importPath.substring(pkgName.length)}`;
const mappedSubPath = findEntrypointTopLevel(
const mappedSubPath = findEntrypointTopLevel({
importer,
importPath,
pkgJsonPath,
packageSubPath,
pkgJson.exports,
exportConditions
);
subPath: packageSubPath,
exportMap: pkgJson.exports,
conditions: exportConditions
});
const pkgDir = path__default['default'].dirname(pkgJsonPath);

@@ -465,2 +510,3 @@ location = path__default['default'].join(pkgDir, mappedSubPath);

async function resolveImportSpecifiers({
importer,
importSpecifierList,

@@ -480,2 +526,3 @@ exportConditions,

const resolved = await resolveId({
importer,
importPath: importSpecifierList[i],

@@ -727,2 +774,3 @@ exportConditions,

const resolvedWithoutBuiltins = await resolveImportSpecifiers({
importer,
importSpecifierList,

@@ -729,0 +777,0 @@ exportConditions,

@@ -222,7 +222,18 @@ import path, { dirname, resolve, extname, normalize, sep } from 'path';

const pathNotFoundError = (subPath, pkgPath) =>
new Error(`Package subpath '${subPath}' is not defined by "exports" in ${pkgPath}`);
const pathNotFoundError = (importPath, importer, subPath, pkgPath) =>
new Error(
`Could not resolve import "${importPath}" in "${importer}".` +
` Package subpath "${subPath}" is not defined by "exports" in ${pkgPath}`
);
function findExportKeyMatch(exportMap, subPath) {
for (const key of Object.keys(exportMap)) {
if (subPath in exportMap) {
return subPath;
}
const matchKeys = Object.keys(exportMap)
.filter((key) => key.endsWith('/') || key.endsWith('*'))
.sort((a, b) => b.length - a.length);
for (const key of matchKeys) {
if (key.endsWith('*')) {

@@ -249,3 +260,3 @@ // star match: "./foo/*": "./foo/*.js"

function mapSubPath(pkgJsonPath, subPath, key, value) {
function mapSubPath({ importPath, importer, pkgJsonPath, subPath, key, value }) {
if (typeof value === 'string') {

@@ -273,8 +284,16 @@ if (typeof key === 'string' && key.endsWith('*')) {

throw pathNotFoundError(subPath, pkgJsonPath);
throw pathNotFoundError(importPath, importer, subPath, pkgJsonPath);
}
function findEntrypoint(pkgJsonPath, subPath, exportMap, conditions, key) {
function findEntrypoint({
importPath,
importer,
pkgJsonPath,
subPath,
exportMap,
conditions,
key
}) {
if (typeof exportMap !== 'object') {
return mapSubPath(pkgJsonPath, subPath, key, exportMap);
return mapSubPath({ importPath, importer, pkgJsonPath, subPath, key, value: exportMap });
}

@@ -285,3 +304,11 @@

if (conditions.includes(condition)) {
const mappedSubPath = findEntrypoint(pkgJsonPath, subPath, subExportMap, conditions, key);
const mappedSubPath = findEntrypoint({
importPath,
importer,
pkgJsonPath,
subPath,
exportMap: subExportMap,
conditions,
key
});
if (mappedSubPath) {

@@ -292,6 +319,13 @@ return mappedSubPath;

}
throw pathNotFoundError(subPath, pkgJsonPath);
throw pathNotFoundError(importer, subPath, pkgJsonPath);
}
function findEntrypointTopLevel(pkgJsonPath, subPath, exportMap, conditions) {
function findEntrypointTopLevel({
importPath,
importer,
pkgJsonPath,
subPath,
exportMap,
conditions
}) {
if (typeof exportMap !== 'object') {

@@ -301,5 +335,5 @@ // the export map shorthand, for example { exports: "./index.js" }

// shorthand only supports a main entrypoint
throw pathNotFoundError(subPath, pkgJsonPath);
throw pathNotFoundError(importPath, importer, subPath, pkgJsonPath);
}
return mapSubPath(pkgJsonPath, subPath, null, exportMap);
return mapSubPath({ importPath, importer, pkgJsonPath, subPath, key: null, value: exportMap });
}

@@ -327,3 +361,3 @@

// package with top level conditions means it only supports a main entrypoint
throw pathNotFoundError(subPath, pkgJsonPath);
throw pathNotFoundError(importPath, importer, subPath, pkgJsonPath);
}

@@ -335,3 +369,3 @@ exportMapForSubPath = exportMap;

if (!key) {
throw pathNotFoundError(subPath, pkgJsonPath);
throw pathNotFoundError(importPath, importer, subPath, pkgJsonPath);
}

@@ -341,6 +375,15 @@ exportMapForSubPath = exportMap[key];

return findEntrypoint(pkgJsonPath, subPath, exportMapForSubPath, conditions, key);
return findEntrypoint({
importPath,
importer,
pkgJsonPath,
subPath,
exportMap: exportMapForSubPath,
conditions,
key
});
}
async function resolveId({
importer,
importPath,

@@ -407,8 +450,10 @@ exportConditions,

pkgName === importPath ? '.' : `.${importPath.substring(pkgName.length)}`;
const mappedSubPath = findEntrypointTopLevel(
const mappedSubPath = findEntrypointTopLevel({
importer,
importPath,
pkgJsonPath,
packageSubPath,
pkgJson.exports,
exportConditions
);
subPath: packageSubPath,
exportMap: pkgJson.exports,
conditions: exportConditions
});
const pkgDir = path.dirname(pkgJsonPath);

@@ -452,2 +497,3 @@ location = path.join(pkgDir, mappedSubPath);

async function resolveImportSpecifiers({
importer,
importSpecifierList,

@@ -467,2 +513,3 @@ exportConditions,

const resolved = await resolveId({
importer,
importPath: importSpecifierList[i],

@@ -714,2 +761,3 @@ exportConditions,

const resolvedWithoutBuiltins = await resolveImportSpecifiers({
importer,
importSpecifierList,

@@ -716,0 +764,0 @@ exportConditions,

{
"name": "@rollup/plugin-node-resolve",
"version": "11.0.0",
"version": "11.0.1",
"publishConfig": {

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

@@ -184,3 +184,3 @@ [npm]: https://img.shields.io/npm/v/@rollup/plugin-node-resolve

To provide stubbed versions of Node built-ins, yse a plugin like [rollup-plugin-node-polyfills](https://github.com/ionic-team/rollup-plugin-node-polyfills) or use [`builtin-modules`](https://github.com/sindresorhus/builtin-modules) with `external`, and set `preferBuiltins` to `false`. e.g.
To provide stubbed versions of Node built-ins, use a plugin like [rollup-plugin-node-polyfills](https://github.com/ionic-team/rollup-plugin-node-polyfills) or use [`builtin-modules`](https://github.com/sindresorhus/builtin-modules) with `external`, and set `preferBuiltins` to `false`. e.g.

@@ -187,0 +187,0 @@ ```js

@@ -0,1 +1,3 @@

import { Plugin } from 'rollup';
export const DEFAULTS: {

@@ -2,0 +4,0 @@ customResolveOptions: {};

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