Socket
Socket
Sign inDemoInstall

enhanced-resolve

Package Overview
Dependencies
2
Maintainers
4
Versions
127
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 5.15.0 to 5.15.1

lib/util/module-browser.js

30

lib/PnpPlugin.js

@@ -13,3 +13,3 @@ /*

* @typedef {Object} PnpApiImpl
* @property {function(string, string, object): string} resolveToUnqualified
* @property {function(string, string, object): string | null} resolveToUnqualified
*/

@@ -22,7 +22,9 @@

* @param {string | ResolveStepHook} target target
* @param {string | ResolveStepHook} alternateTarget alternateTarget
*/
constructor(source, pnpApi, target) {
constructor(source, pnpApi, target, alternateTarget) {
this.source = source;
this.pnpApi = pnpApi;
this.target = target;
this.alternateTarget = alternateTarget;
}

@@ -37,2 +39,3 @@

const target = resolver.ensureHook(this.target);
const alternateTarget = resolver.ensureHook(this.alternateTarget);
resolver

@@ -53,5 +56,5 @@ .getHook(this.source)

/** @type {string|undefined} */
/** @type {string|undefined|null} */
let resolution;
/** @type {string|undefined} */
/** @type {string|undefined|null} */
let apiResolution;

@@ -62,2 +65,21 @@ try {

});
if (resolution === null) {
// This is either not a PnP managed issuer or it's a Node builtin
// Try to continue resolving with our alternatives
resolver.doResolve(
alternateTarget,
request,
"issuer is not managed by a pnpapi",
resolveContext,
(err, result) => {
if (err) return callback(err);
if (result) return callback(null, result);
// Skip alternatives
return callback(null, null);
}
);
return;
}
if (resolveContext.fileDependencies) {

@@ -64,0 +86,0 @@ apiResolution = this.pnpApi.resolveToUnqualified("pnpapi", issuer, {

@@ -128,4 +128,23 @@ /*

) {
// @ts-ignore
return require("pnpapi"); // eslint-disable-line node/no-missing-require
const _findPnpApi =
/** @type {function(string): PnpApi | null}} */
(
// @ts-ignore
require("module").findPnpApi
);
if (_findPnpApi) {
return {
resolveToUnqualified(request, issuer, opts) {
const pnpapi = _findPnpApi(issuer);
if (!pnpapi) {
// Issuer isn't managed by PnP
return null;
}
return pnpapi.resolveToUnqualified(request, issuer, opts);
}
};
}
}

@@ -309,2 +328,3 @@

resolver.ensureHook("rawModule");
resolver.ensureHook("alternateRawModule");
resolver.ensureHook("module");

@@ -451,4 +471,17 @@ resolver.ensureHook("resolveAsModule");

plugins.push(
new PnpPlugin("raw-module", pnpApi, "undescribed-resolve-in-package")
new PnpPlugin(
"raw-module",
pnpApi,
"undescribed-resolve-in-package",
"alternate-raw-module"
)
);
plugins.push(
new ModulesInHierarchicalDirectoriesPlugin(
"alternate-raw-module",
["node_modules"],
"module"
)
);
} else {

@@ -455,0 +488,0 @@ plugins.push(

6

package.json
{
"name": "enhanced-resolve",
"version": "5.15.0",
"version": "5.15.1",
"author": "Tobias Koppers @sokra",

@@ -12,4 +12,4 @@ "description": "Offers a async require.resolve function. It's highly configurable.",

"browser": {
"pnpapi": false,
"process": "./lib/util/process-browser.js"
"process": "./lib/util/process-browser.js",
"module": "./lib/util/module-browser.js"
},

@@ -16,0 +16,0 @@ "dependencies": {

@@ -292,3 +292,7 @@ /*

declare interface PnpApiImpl {
resolveToUnqualified: (arg0: string, arg1: string, arg2: object) => string;
resolveToUnqualified: (
arg0: string,
arg1: string,
arg2: object
) => null | string;
}

@@ -295,0 +299,0 @@ declare interface PossibleFileSystemError {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc