Socket
Socket
Sign inDemoInstall

enhanced-resolve

Package Overview
Dependencies
2
Maintainers
2
Versions
127
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 5.9.3 to 5.10.0

lib/ExtensionAliasPlugin.js

4

lib/ExportsFieldPlugin.js

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

const { parseIdentifier } = require("./util/identifier");
const { checkExportsFieldTarget } = require("./util/path");
const { checkImportsExportsFieldTarget } = require("./util/path");

@@ -120,3 +120,3 @@ /** @typedef {import("./Resolver")} Resolver */

const error = checkExportsFieldTarget(relativePath);
const error = checkImportsExportsFieldTarget(relativePath);

@@ -123,0 +123,0 @@ if (error) {

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

const { parseIdentifier } = require("./util/identifier");
const { checkImportsExportsFieldTarget } = require("./util/path");

@@ -122,2 +123,8 @@ /** @typedef {import("./Resolver")} Resolver */

const error = checkImportsExportsFieldTarget(path_);
if (error) {
return callback(error);
}
switch (path_.charCodeAt(0)) {

@@ -124,0 +131,0 @@ // should be relative

@@ -266,3 +266,3 @@ /*

if (typeof request !== "string")
return callback(new Error("path argument is not a string"));
return callback(new Error("request argument is not a string"));
if (!resolveContext)

@@ -269,0 +269,0 @@ return callback(new Error("resolveContext argument is not set"));

@@ -21,2 +21,3 @@ /*

const ExportsFieldPlugin = require("./ExportsFieldPlugin");
const ExtensionAliasPlugin = require("./ExtensionAliasPlugin");
const FileExistsPlugin = require("./FileExistsPlugin");

@@ -42,2 +43,3 @@ const ImportsFieldPlugin = require("./ImportsFieldPlugin");

/** @typedef {import("./AliasPlugin").AliasOption} AliasOptionEntry */
/** @typedef {import("./ExtensionAliasPlugin").ExtensionAliasOption} ExtensionAliasOption */
/** @typedef {import("./PnpPlugin").PnpApiImpl} PnpApi */

@@ -50,2 +52,3 @@ /** @typedef {import("./Resolver").FileSystem} FileSystem */

/** @typedef {{[k: string]: AliasOptionNewRequest}} AliasOptions */
/** @typedef {{[k: string]: string|string[] }} ExtensionAliasOptions */
/** @typedef {{apply: function(Resolver): void} | function(this: Resolver, Resolver): void} Plugin */

@@ -57,2 +60,3 @@

* @property {(AliasOptions | AliasOptionEntry[])=} fallback A list of module alias configurations or an object which maps key to value, applied only after modules option
* @property {ExtensionAliasOptions=} extensionAlias An object which maps extension to extension aliases
* @property {(string | string[])[]=} aliasFields A list of alias fields in description files

@@ -90,2 +94,3 @@ * @property {(function(ResolveRequest): boolean)=} cachePredicate A function which decides whether a request should be cached or not. An object is passed with at least `path` and `request` properties.

* @property {Set<string | string[]>} aliasFields
* @property {ExtensionAliasOption[]} extensionAlias
* @property {(function(ResolveRequest): boolean)} cachePredicate

@@ -205,2 +210,10 @@ * @property {boolean} cacheWithContext

extensions: new Set(options.extensions || [".js", ".json", ".node"]),
extensionAlias: options.extensionAlias
? Object.keys(options.extensionAlias).map(k => ({
extension: k,
alias: /** @type {ExtensionAliasOptions} */ (options.extensionAlias)[
k
]
}))
: [],
fileSystem: options.useSyncFileSystemCalls

@@ -260,2 +273,3 @@ ? new SyncAsyncFileSystemDecorator(

exportsFields,
extensionAlias,
importsFields,

@@ -293,2 +307,4 @@ extensions,

resolver.ensureHook("describedResolve");
resolver.ensureHook("rawResolve");
resolver.ensureHook("normalResolve");
resolver.ensureHook("internal");

@@ -353,3 +369,3 @@ resolver.ensureHook("rawModule");

// described-resolve
plugins.push(new NextPlugin("described-resolve", "normal-resolve"));
plugins.push(new NextPlugin("described-resolve", "raw-resolve"));
if (fallback.length > 0) {

@@ -361,10 +377,17 @@ plugins.push(

// normal-resolve
if (alias.length > 0)
plugins.push(new AliasPlugin("normal-resolve", alias, "internal-resolve"));
// raw-resolve
if (alias.length > 0) {
plugins.push(new AliasPlugin("raw-resolve", alias, "internal-resolve"));
}
aliasFields.forEach(item => {
plugins.push(new AliasFieldPlugin("raw-resolve", item, "internal-resolve"));
});
extensionAlias.forEach(item =>
plugins.push(
new AliasFieldPlugin("normal-resolve", item, "internal-resolve")
);
});
new ExtensionAliasPlugin("raw-resolve", item, "normal-resolve")
)
);
plugins.push(new NextPlugin("raw-resolve", "normal-resolve"));
// normal-resolve
if (preferRelative) {

@@ -371,0 +394,0 @@ plugins.push(new JoinRequestPlugin("after-normal-resolve", "relative"));

@@ -195,5 +195,5 @@ /*

const checkExportsFieldTarget = relativePath => {
let lastNonSlashIndex = 2;
let slashIndex = relativePath.indexOf("/", 2);
const checkImportsExportsFieldTarget = relativePath => {
let lastNonSlashIndex = 0;
let slashIndex = relativePath.indexOf("/", 1);
let cd = 0;

@@ -213,2 +213,4 @@

}
case ".":
break;
default:

@@ -223,2 +225,2 @@ cd++;

};
exports.checkExportsFieldTarget = checkExportsFieldTarget;
exports.checkImportsExportsFieldTarget = checkImportsExportsFieldTarget;
{
"name": "enhanced-resolve",
"version": "5.9.3",
"version": "5.10.0",
"author": "Tobias Koppers @sokra",

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

@@ -80,5 +80,6 @@ # enhanced-resolve

| Field | Default | Description |
| ---------------- | --------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
|------------------|-----------------------------| --------------------------------------------------------------------------------------------------------------------------------------------------------- |
| alias | [] | A list of module alias configurations or an object which maps key to value |
| aliasFields | [] | A list of alias fields in description files |
| extensionAlias | {} | An object which maps extension to extension aliases |
| cachePredicate | function() { return true }; | A function which decides whether a request should be cached or not. An object is passed to the function with `path` and `request` properties. |

@@ -146,3 +147,3 @@ | cacheWithContext | true | If unsafe cache is enabled, includes `request.context` in the cache key |

```javascript
npm test
yarn test
```

@@ -149,0 +150,0 @@

@@ -94,2 +94,9 @@ /*

}
declare interface ExtensionAliasOption {
alias: string | string[];
extension: string;
}
declare interface ExtensionAliasOptions {
[index: string]: string | string[];
}
declare interface FileSystem {

@@ -218,2 +225,3 @@ readFile: {

aliasFields: Set<string | string[]>;
extensionAlias: ExtensionAliasOption[];
cachePredicate: (arg0: ResolveRequest) => boolean;

@@ -328,2 +336,7 @@ cacheWithContext: boolean;

/**
* An object which maps extension to extension aliases
*/
extensionAlias?: ExtensionAliasOptions;
/**
* A list of alias fields in description files

@@ -330,0 +343,0 @@ */

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