Socket
Socket
Sign inDemoInstall

enhanced-resolve

Package Overview
Dependencies
Maintainers
4
Versions
130
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

enhanced-resolve - npm Package Compare versions

Comparing version 5.0.0-beta.12 to 5.0.0

30

lib/CachedInputFileSystem.js

@@ -380,4 +380,6 @@ /*

);
this.stat = /** @type {FileSystem["stat"]} */ (this._statBackend.provide);
this.statSync = /** @type {SyncFileSystem["statSync"]} */ (this._statBackend.provideSync);
const stat = this._statBackend.provide;
this.stat = /** @type {FileSystem["stat"]} */ (stat);
const statSync = this._statBackend.provideSync;
this.statSync = /** @type {SyncFileSystem["statSync"]} */ (statSync);

@@ -390,4 +392,6 @@ this._readdirBackend = createBackend(

);
this.readdir = /** @type {FileSystem["readdir"]} */ (this._readdirBackend.provide);
this.readdirSync = /** @type {SyncFileSystem["readdirSync"]} */ (this._readdirBackend.provideSync);
const readdir = this._readdirBackend.provide;
this.readdir = /** @type {FileSystem["readdir"]} */ (readdir);
const readdirSync = this._readdirBackend.provideSync;
this.readdirSync = /** @type {SyncFileSystem["readdirSync"]} */ (readdirSync);

@@ -400,4 +404,6 @@ this._readFileBackend = createBackend(

);
this.readFile = /** @type {FileSystem["readFile"]} */ (this._readFileBackend.provide);
this.readFileSync = /** @type {SyncFileSystem["readFileSync"]} */ (this._readFileBackend.provideSync);
const readFile = this._readFileBackend.provide;
this.readFile = /** @type {FileSystem["readFile"]} */ (readFile);
const readFileSync = this._readFileBackend.provideSync;
this.readFileSync = /** @type {SyncFileSystem["readFileSync"]} */ (readFileSync);

@@ -432,4 +438,6 @@ this._readJsonBackend = createBackend(

);
this.readJson = /** @type {FileSystem["readJson"]} */ (this._readJsonBackend.provide);
this.readJsonSync = /** @type {SyncFileSystem["readJsonSync"]} */ (this._readJsonBackend.provideSync);
const readJson = this._readJsonBackend.provide;
this.readJson = /** @type {FileSystem["readJson"]} */ (readJson);
const readJsonSync = this._readJsonBackend.provideSync;
this.readJsonSync = /** @type {SyncFileSystem["readJsonSync"]} */ (readJsonSync);

@@ -442,4 +450,6 @@ this._readlinkBackend = createBackend(

);
this.readlink = /** @type {FileSystem["readlink"]} */ (this._readlinkBackend.provide);
this.readlinkSync = /** @type {SyncFileSystem["readlinkSync"]} */ (this._readlinkBackend.provideSync);
const readlink = this._readlinkBackend.provide;
this.readlink = /** @type {FileSystem["readlink"]} */ (readlink);
const readlinkSync = this._readlinkBackend.provideSync;
this.readlinkSync = /** @type {SyncFileSystem["readlinkSync"]} */ (readlinkSync);
}

@@ -446,0 +456,0 @@

@@ -66,3 +66,3 @@ /*

const resolver = ResolverFactory.createResolver(options);
return function(context, path, request, resolveContext, callback) {
return function (context, path, request, resolveContext, callback) {
if (typeof context === "string") {

@@ -89,3 +89,3 @@ callback = resolveContext;

const resolver = ResolverFactory.createResolver(options);
return function(context, path, request) {
return function (context, path, request) {
if (typeof context === "string") {

@@ -92,0 +92,0 @@ request = path;

@@ -54,2 +54,15 @@ /*

} catch (error) {
if (
error.code === "MODULE_NOT_FOUND" &&
error.pnpCode === "UNDECLARED_DEPENDENCY"
) {
// This is not a PnP managed dependency.
// Try to continue resolving with our alternatives
if (resolveContext.log) {
resolveContext.log(`request is not managed by the pnpapi`);
for (const line of error.message.split("\n").filter(Boolean))
resolveContext.log(` ${line}`);
}
return callback();
}
return callback(error);

@@ -56,0 +69,0 @@ }

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

/** @typedef {import("./Resolver").ResolveRequest} ResolveRequest */
/** @typedef {import("./Resolver").SyncFileSystem} SyncFileSystem */

@@ -175,3 +176,3 @@ /** @typedef {string|string[]|false} AliasOptionNewRequest */

options.cachePredicate ||
function() {
function () {
return true;

@@ -192,3 +193,7 @@ },

fileSystem: options.useSyncFileSystemCalls
? new SyncAsyncFileSystemDecorator(options.fileSystem)
? new SyncAsyncFileSystemDecorator(
/** @type {SyncFileSystem} */ (
/** @type {unknown} */ (options.fileSystem)
)
)
: options.fileSystem,

@@ -227,3 +232,3 @@ unsafeCache:

*/
exports.createResolver = function(options) {
exports.createResolver = function (options) {
const normalizedOptions = createOptions(options);

@@ -382,11 +387,13 @@

});
if (pnpApi) {
plugins.push(new PnpPlugin("raw-module", pnpApi, "relative"));
}
modules.forEach(item => {
if (Array.isArray(item))
if (Array.isArray(item)) {
plugins.push(
new ModulesInHierachicDirectoriesPlugin("raw-module", item, "module")
);
else plugins.push(new ModulesInRootPlugin("raw-module", item, "module"));
if (item.includes("node_modules") && pnpApi) {
plugins.push(new PnpPlugin("raw-module", pnpApi, "relative"));
}
} else {
plugins.push(new ModulesInRootPlugin("raw-module", item, "module"));
}
});

@@ -393,0 +400,0 @@

@@ -8,68 +8,63 @@ /*

/** @typedef {import("./Resolver").FileSystem} FileSystem */
/** @typedef {import("./Resolver").SyncFileSystem} SyncFileSystem */
/**
* @param {Object} fs file system implementation
* @param {SyncFileSystem} fs file system implementation
* @constructor
*/
function SyncAsyncFileSystemDecorator(fs) {
/**
* @type {Object}
*/
this.fs = fs;
if (fs.statSync) {
this.stat = (arg, callback) => {
let result;
try {
result = fs.statSync(arg);
} catch (e) {
return callback(e);
}
callback(null, result);
};
this.stat = (arg, callback) => {
let result;
try {
result = fs.statSync(arg);
} catch (e) {
return callback(e);
}
callback(null, result);
};
this.statSync = arg => fs.statSync(arg);
this.statSync = arg => fs.statSync(arg);
}
if (fs.readdirSync) {
this.readdir = (arg, callback) => {
let result;
try {
result = fs.readdirSync(arg);
} catch (e) {
return callback(e);
}
callback(null, result);
};
this.readdir = (arg, callback) => {
let result;
try {
result = fs.readdirSync(arg);
} catch (e) {
return callback(e);
}
callback(null, result);
};
this.readdirSync = arg => fs.readdirSync(arg);
this.readdirSync = arg => fs.readdirSync(arg);
}
if (fs.readFileSync) {
this.readFile = (arg, callback) => {
let result;
try {
result = fs.readFileSync(arg);
} catch (e) {
return callback(e);
}
callback(null, result);
};
this.readFile = (arg, callback) => {
let result;
try {
result = fs.readFileSync(arg);
} catch (e) {
return callback(e);
}
callback(null, result);
};
this.readFileSync = arg => fs.readFileSync(arg);
this.readFileSync = arg => fs.readFileSync(arg);
}
if (fs.readlinkSync) {
this.readlink = (arg, callback) => {
let result;
try {
result = fs.readlinkSync(arg);
} catch (e) {
return callback(e);
}
callback(null, result);
};
this.readlink = (arg, callback) => {
let result;
try {
result = fs.readlinkSync(arg);
} catch (e) {
return callback(e);
}
callback(null, result);
};
this.readlinkSync = arg => fs.readlinkSync(arg);
this.readlinkSync = arg => fs.readlinkSync(arg);
}
if (fs.readJsonSync) {
this.readJson = undefined;
this.readJsonSync = undefined;
const readJsonSync = fs.readJsonSync;
if (readJsonSync) {
this.readJson = (arg, callback) => {
let result;
try {
result = fs.readJsonSync(arg);
result = readJsonSync.call(fs, arg);
} catch (e) {

@@ -81,5 +76,5 @@ return callback(e);

this.readJsonSync = arg => fs.readJsonSync(arg);
this.readJsonSync = arg => readJsonSync.call(fs, arg);
}
}
module.exports = SyncAsyncFileSystemDecorator;
{
"name": "enhanced-resolve",
"version": "5.0.0-beta.12",
"version": "5.0.0",
"author": "Tobias Koppers @sokra",

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

"dependencies": {
"graceful-fs": "^4.2.0",
"tapable": "^2.0.0-beta.10"
"graceful-fs": "^4.2.4",
"tapable": "^2.0.0"
},
"license": "MIT",
"devDependencies": {
"@types/mocha": "^7.0.2",
"@types/node": "^13.7.7",
"eslint": "^6.8.0",
"eslint-config-prettier": "^6.10.0",
"eslint-plugin-jsdoc": "^22.0.0",
"eslint-plugin-node": "^11.0.0",
"eslint-plugin-prettier": "^3.1.2",
"husky": "^1.2.0",
"lint-staged": "^8.1.0",
"memfs": "^2.15.4",
"mocha": "^7.1.0",
"nyc": "^14.1.1",
"prettier": "^1.15.2",
"@types/mocha": "^8.0.3",
"@types/node": "^14.11.1",
"eslint": "^7.9.0",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-jsdoc": "^30.5.1",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^3.1.4",
"husky": "^4.3.0",
"lint-staged": "^10.4.0",
"memfs": "^3.2.0",
"mocha": "^8.1.3",
"nyc": "^15.1.0",
"prettier": "^2.1.2",
"should": "^13.2.3",
"tooling": "webpack/tooling#v1.6.0",
"typescript": "^3.8.3"
"tooling": "webpack/tooling#v1.8.0",
"typescript": "^4.0.2"
},

@@ -49,3 +49,3 @@ "engines": {

"special-lint-fix": "node node_modules/tooling/inherit-types --write && node node_modules/tooling/format-file-header --write && node node_modules/tooling/generate-types --write",
"pretty": "prettier --loglevel warn --write \"{lib,test}/**/*.{js,json}\"",
"pretty": "prettier --loglevel warn --write \"lib/**/*.{js,json}\" \"test/*.js\"",
"pretest": "yarn lint",

@@ -52,0 +52,0 @@ "test": "mocha --full-trace --check-leaks",

@@ -11,8 +11,8 @@ /*

path: string | false;
descriptionFilePath?: undefined | string;
descriptionFileRoot?: undefined | string;
descriptionFilePath?: string;
descriptionFileRoot?: string;
descriptionFileData?: any;
relativePath?: undefined | string;
ignoreSymlinks?: undefined | boolean;
fullySpecified?: undefined | boolean;
relativePath?: string;
ignoreSymlinks?: boolean;
fullySpecified?: boolean;
}

@@ -30,3 +30,3 @@ declare class CachedInputFileSystem {

arg0: string,
arg1: FileSystemCallback<(string | Buffer)[] | (FileSystemDirent)[]>
arg1: FileSystemCallback<(string | Buffer)[] | FileSystemDirent[]>
): void;

@@ -36,3 +36,3 @@ (

arg1: any,
arg2: FileSystemCallback<(string | Buffer)[] | (FileSystemDirent)[]>
arg2: FileSystemCallback<(string | Buffer)[] | FileSystemDirent[]>
): void;

@@ -43,3 +43,3 @@ };

arg1?: any
) => (string | Buffer)[] | (FileSystemDirent)[];
) => (string | Buffer)[] | FileSystemDirent[];
readFile: {

@@ -76,3 +76,3 @@ (arg0: string, arg1: FileSystemCallback<string | Buffer>): void;

arg0: string,
arg1: FileSystemCallback<(string | Buffer)[] | (FileSystemDirent)[]>
arg1: FileSystemCallback<(string | Buffer)[] | FileSystemDirent[]>
): void;

@@ -82,11 +82,9 @@ (

arg1: any,
arg2: FileSystemCallback<(string | Buffer)[] | (FileSystemDirent)[]>
arg2: FileSystemCallback<(string | Buffer)[] | FileSystemDirent[]>
): void;
};
readJson?:
| undefined
| {
(arg0: string, arg1: FileSystemCallback<any>): void;
(arg0: string, arg1: any, arg2: FileSystemCallback<any>): void;
};
readJson?: {
(arg0: string, arg1: FileSystemCallback<any>): void;
(arg0: string, arg1: any, arg2: FileSystemCallback<any>): void;
};
readlink: {

@@ -102,6 +100,3 @@ (arg0: string, arg1: FileSystemCallback<string | Buffer>): void;

declare interface FileSystemCallback<T> {
(
err: undefined | null | (PossibleFileSystemError & Error),
result?: undefined | T
): any;
(err?: null | (PossibleFileSystemError & Error), result?: T): any;
}

@@ -135,6 +130,6 @@ declare interface FileSystemDirent {

declare interface PossibleFileSystemError {
code?: undefined | string;
errno?: undefined | number;
path?: undefined | string;
syscall?: undefined | string;
code?: string;
errno?: number;
path?: string;
syscall?: string;
}

@@ -146,3 +141,3 @@

declare interface ResolveContext {
contextDependencies?: undefined | { add: (T?: any) => void };
contextDependencies?: { add: (T?: any) => void };

@@ -152,3 +147,3 @@ /**

*/
fileDependencies?: undefined | { add: (T?: any) => void };
fileDependencies?: { add: (T?: any) => void };

@@ -158,3 +153,3 @@ /**

*/
missingDependencies?: undefined | { add: (T?: any) => void };
missingDependencies?: { add: (T?: any) => void };

@@ -164,3 +159,3 @@ /**

*/
stack?: undefined | Set<string>;
stack?: Set<string>;

@@ -170,16 +165,16 @@ /**

*/
log?: undefined | ((arg0: string) => void);
log?: (arg0: string) => void;
}
declare interface ResolveOptions {
alias: ({
alias: string | false | (string)[];
alias: {
alias: string | false | string[];
name: string;
onlyModule?: undefined | boolean;
})[];
fallback: ({
alias: string | false | (string)[];
onlyModule?: boolean;
}[];
fallback: {
alias: string | false | string[];
name: string;
onlyModule?: undefined | boolean;
})[];
aliasFields: Set<string | (string)[]>;
onlyModule?: boolean;
}[];
aliasFields: Set<string | string[]>;
cachePredicate: (

@@ -194,6 +189,6 @@ arg0: BaseResolveRequest & Partial<ParsedIdentifier>

conditionNames: Set<string>;
descriptionFiles: (string)[];
descriptionFiles: string[];
enforceExtension: boolean;
exportsFields: Set<string | (string)[]>;
importsFields: Set<string | (string)[]>;
exportsFields: Set<string | string[]>;
importsFields: Set<string | string[]>;
extensions: Set<string>;

@@ -203,9 +198,10 @@ fileSystem: FileSystem;

symlinks: boolean;
resolver?: undefined | Resolver;
modules: (string | (string)[])[];
mainFields: ({ name: (string)[]; forceRelative: boolean })[];
resolver?: Resolver;
modules: (string | string[])[];
mainFields: { name: string[]; forceRelative: boolean }[];
mainFiles: Set<string>;
plugins: (
| { apply: (arg0: Resolver) => void }
| ((this: Resolver, arg1: Resolver) => void))[];
| ((this: Resolver, arg1: Resolver) => void)
)[];
pnpApi: null | PnpApiImpl;

@@ -224,6 +220,6 @@ roots: Set<string>;

AsyncSeriesBailHook<
[(BaseResolveRequest & Partial<ParsedIdentifier>), ResolveContext],
[BaseResolveRequest & Partial<ParsedIdentifier>, ResolveContext],
null | (BaseResolveRequest & Partial<ParsedIdentifier>)
>,
(BaseResolveRequest & Partial<ParsedIdentifier>)
BaseResolveRequest & Partial<ParsedIdentifier>
],

@@ -233,11 +229,11 @@ void

noResolve: SyncHook<
[(BaseResolveRequest & Partial<ParsedIdentifier>), Error],
[BaseResolveRequest & Partial<ParsedIdentifier>, Error],
void
>;
resolve: AsyncSeriesBailHook<
[(BaseResolveRequest & Partial<ParsedIdentifier>), ResolveContext],
[BaseResolveRequest & Partial<ParsedIdentifier>, ResolveContext],
null | (BaseResolveRequest & Partial<ParsedIdentifier>)
>;
result: AsyncSeriesHook<
[(BaseResolveRequest & Partial<ParsedIdentifier>), ResolveContext]
[BaseResolveRequest & Partial<ParsedIdentifier>, ResolveContext]
>;

@@ -249,7 +245,7 @@ };

| AsyncSeriesBailHook<
[(BaseResolveRequest & Partial<ParsedIdentifier>), ResolveContext],
[BaseResolveRequest & Partial<ParsedIdentifier>, ResolveContext],
null | (BaseResolveRequest & Partial<ParsedIdentifier>)
>
): AsyncSeriesBailHook<
[(BaseResolveRequest & Partial<ParsedIdentifier>), ResolveContext],
[BaseResolveRequest & Partial<ParsedIdentifier>, ResolveContext],
null | (BaseResolveRequest & Partial<ParsedIdentifier>)

@@ -261,7 +257,7 @@ >;

| AsyncSeriesBailHook<
[(BaseResolveRequest & Partial<ParsedIdentifier>), ResolveContext],
[BaseResolveRequest & Partial<ParsedIdentifier>, ResolveContext],
null | (BaseResolveRequest & Partial<ParsedIdentifier>)
>
): AsyncSeriesBailHook<
[(BaseResolveRequest & Partial<ParsedIdentifier>), ResolveContext],
[BaseResolveRequest & Partial<ParsedIdentifier>, ResolveContext],
null | (BaseResolveRequest & Partial<ParsedIdentifier>)

@@ -277,4 +273,4 @@ >;

arg0: null | Error,
arg1: undefined | string | false,
arg2: undefined | (BaseResolveRequest & Partial<ParsedIdentifier>)
arg1?: string | false,
arg2?: BaseResolveRequest & Partial<ParsedIdentifier>
) => void

@@ -301,9 +297,8 @@ ): void;

alias?:
| undefined
| { [index: string]: string | false | (string)[] }
| ({
alias: string | false | (string)[];
| { [index: string]: string | false | string[] }
| {
alias: string | false | string[];
name: string;
onlyModule?: undefined | boolean;
})[];
onlyModule?: boolean;
}[];

@@ -314,9 +309,8 @@ /**

fallback?:
| undefined
| { [index: string]: string | false | (string)[] }
| ({
alias: string | false | (string)[];
| { [index: string]: string | false | string[] }
| {
alias: string | false | string[];
name: string;
onlyModule?: undefined | boolean;
})[];
onlyModule?: boolean;
}[];

@@ -326,3 +320,3 @@ /**

*/
aliasFields?: undefined | (string | (string)[])[];
aliasFields?: (string | string[])[];

@@ -332,5 +326,5 @@ /**

*/
cachePredicate?:
| undefined
| ((arg0: BaseResolveRequest & Partial<ParsedIdentifier>) => boolean);
cachePredicate?: (
arg0: BaseResolveRequest & Partial<ParsedIdentifier>
) => boolean;

@@ -340,3 +334,3 @@ /**

*/
cacheWithContext?: undefined | boolean;
cacheWithContext?: boolean;

@@ -346,3 +340,3 @@ /**

*/
descriptionFiles?: undefined | (string)[];
descriptionFiles?: string[];

@@ -352,3 +346,3 @@ /**

*/
conditionNames?: undefined | (string)[];
conditionNames?: string[];

@@ -358,3 +352,3 @@ /**

*/
enforceExtension?: undefined | boolean;
enforceExtension?: boolean;

@@ -364,3 +358,3 @@ /**

*/
exportsFields?: undefined | (string | (string)[])[];
exportsFields?: (string | string[])[];

@@ -370,3 +364,3 @@ /**

*/
importsFields?: undefined | (string | (string)[])[];
importsFields?: (string | string[])[];

@@ -376,3 +370,3 @@ /**

*/
extensions?: undefined | (string)[];
extensions?: string[];

@@ -392,3 +386,3 @@ /**

*/
symlinks?: undefined | boolean;
symlinks?: boolean;

@@ -398,3 +392,3 @@ /**

*/
resolver?: undefined | Resolver;
resolver?: Resolver;

@@ -404,3 +398,3 @@ /**

*/
modules?: undefined | string | (string)[];
modules?: string | string[];

@@ -410,8 +404,7 @@ /**

*/
mainFields?:
| undefined
| (
| string
| (string)[]
| { name: string | (string)[]; forceRelative: boolean })[];
mainFields?: (
| string
| string[]
| { name: string | string[]; forceRelative: boolean }
)[];

@@ -421,3 +414,3 @@ /**

*/
mainFiles?: undefined | (string)[];
mainFiles?: string[];

@@ -427,7 +420,6 @@ /**

*/
plugins?:
| undefined
| (
| { apply: (arg0: Resolver) => void }
| ((this: Resolver, arg1: Resolver) => void))[];
plugins?: (
| { apply: (arg0: Resolver) => void }
| ((this: Resolver, arg1: Resolver) => void)
)[];

@@ -437,3 +429,3 @@ /**

*/
pnpApi?: undefined | null | PnpApiImpl;
pnpApi?: null | PnpApiImpl;

@@ -443,3 +435,3 @@ /**

*/
roots?: undefined | (string)[];
roots?: string[];

@@ -449,3 +441,3 @@ /**

*/
fullySpecified?: undefined | boolean;
fullySpecified?: boolean;

@@ -455,3 +447,3 @@ /**

*/
resolveToContext?: undefined | boolean;
resolveToContext?: boolean;

@@ -461,3 +453,3 @@ /**

*/
restrictions?: undefined | (string | RegExp)[];
restrictions?: (string | RegExp)[];

@@ -467,3 +459,3 @@ /**

*/
useSyncFileSystemCalls?: undefined | boolean;
useSyncFileSystemCalls?: boolean;
}

@@ -470,0 +462,0 @@ declare function exports(

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