New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

jest-resolve

Package Overview
Dependencies
Maintainers
3
Versions
274
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jest-resolve - npm Package Compare versions

Comparing version 14.1.0 to 14.2.0-alpha.ca8bfb6e

185

build/index.js

@@ -16,8 +16,2 @@ /**

const H = require('jest-haste-map').H;
const nodeModulesPaths = require('resolve/lib/node-modules-paths');

@@ -51,3 +45,3 @@ const path = require('path');

const nodePaths =
const nodePaths =
process.env.NODE_PATH ? process.env.NODE_PATH.split(path.delimiter) : null;

@@ -61,22 +55,19 @@

constructor(moduleMap, options) {
this._options = {
defaultPlatform: options.defaultPlatform,
extensions: options.extensions,
hasCoreModules:
options.hasCoreModules === undefined ? true : options.hasCoreModules,
moduleDirectories: options.moduleDirectories || ['node_modules'],
moduleNameMapper: options.moduleNameMapper,
modulePaths: options.modulePaths,
browser: options.browser };
this._options = {
browser: options.browser,
defaultPlatform: options.defaultPlatform,
extensions: options.extensions,
hasCoreModules:
options.hasCoreModules === undefined ? true : options.hasCoreModules,
moduleDirectories: options.moduleDirectories || ['node_modules'],
moduleNameMapper: options.moduleNameMapper,
modulePaths: options.modulePaths,
platforms: options.platforms };
this._supportsNativePlatform =
(options.platforms || []).indexOf(NATIVE_PLATFORM) !== -1;
this._moduleMap = moduleMap;
this._moduleNameCache = Object.create(null);
this._modulePathCache = Object.create(null);}
this._modulePathCache = Object.create(null);
}
static findNodeModule(path, options) {

@@ -87,18 +78,18 @@ const paths = options.paths;

return resv.sync(
path,
{
basedir: options.basedir,
extensions: options.extensions,
moduleDirectory: options.moduleDirectory,
paths: paths ? (nodePaths || []).concat(paths) : nodePaths });}
path,
{
basedir: options.basedir,
extensions: options.extensions,
moduleDirectory: options.moduleDirectory,
paths: paths ? (nodePaths || []).concat(paths) : nodePaths });
catch (e) {}
return null;}
} catch (e) {}
return null;
}
resolveModule(
from,
moduleName,
options)
from,
moduleName,
options)
{

@@ -114,19 +105,19 @@ const dirname = path.dirname(from);

if (this._moduleNameCache[key]) {
return this._moduleNameCache[key];}
return this._moduleNameCache[key];
}
// 1. Check if the module is a haste module.
let module = this.getModule(moduleName);
if (module) {
return this._moduleNameCache[key] = module;}
return this._moduleNameCache[key] = module;
}
// 2. Check if the module is a node module and resolve it based on
// the node module resolution algorithm.
if (!options || !options.skipNodeResolution) {
module = Resolver.findNodeModule(moduleName, {
basedir: dirname,
browser: this._options.browser,
extensions,
moduleDirectory,
module = Resolver.findNodeModule(moduleName, {
basedir: dirname,
browser: this._options.browser,
extensions,
moduleDirectory,
paths });

@@ -136,6 +127,6 @@

if (module) {
return this._moduleNameCache[key] = module;}}
return this._moduleNameCache[key] = module;
}
}
// 3. Resolve "haste packages" which are `package.json` files outside of

@@ -148,7 +139,7 @@ // `node_modules` folders anywhere in the file system.

return this._moduleNameCache[key] = require.resolve(
path.join.apply(path, [path.dirname(module)].concat(parts)));}
path.join.apply(path, [path.dirname(module)].concat(parts)));
catch (ignoredError) {}}
} catch (ignoredError) {}
}
// 4. Throw an error if the module could not be found. `resolve.sync`

@@ -162,45 +153,38 @@ // only produces an error based on the dirname but we have the actual

err.code = 'MODULE_NOT_FOUND';
throw err;}
throw err;
}
isCoreModule(moduleName) {
return this._options.hasCoreModules && resolve.isCore(moduleName);}
return this._options.hasCoreModules && resolve.isCore(moduleName);
}
getModule(name) {
return this._moduleMap.getModule(
name,
this._options.defaultPlatform,
this._supportsNativePlatform());
getModule(name, type) {
if (!type) {
type = H.MODULE;}
}
const map = this._moduleMap.map[name];
if (map) {
const platform = this._options.defaultPlatform;
let module = platform && map[platform];
if (!module && map[NATIVE_PLATFORM] && this._supportsNativePlatform) {
module = map[NATIVE_PLATFORM];} else
if (!module) {
module = map[H.GENERIC_PLATFORM];}
if (module && module[H.TYPE] === type) {
return module[H.PATH];}}
return null;}
getPackage(name) {
return this.getModule(name, H.PACKAGE);}
return this._moduleMap.getPackage(
name,
this._options.defaultPlatform,
this._supportsNativePlatform());
}
getMockModule(name) {
if (this._moduleMap.mocks[name]) {
return this._moduleMap.mocks[name];} else
{
const moduleName = this._resolveStubModuleName(name);
getMockModule(from, name) {
const mock = this._moduleMap.getMockModule(name);
if (mock) {
return mock;
} else {
const moduleName = this._resolveStubModuleName(from, name);
if (moduleName) {
return this.getModule(moduleName) || moduleName;}}
return this.getModule(moduleName) || moduleName;
}
}
return null;
}
return null;}
getModulePaths(from) {

@@ -212,10 +196,15 @@ if (!this._modulePathCache[from]) {

// circumvent node-resolve bug that adds `undefined` as last item.
paths.pop();}
paths.pop();
}
this._modulePathCache[from] = paths;
}
return this._modulePathCache[from];
}
this._modulePathCache[from] = paths;}
_resolveStubModuleName(from, moduleName) {
const dirname = path.dirname(from);
const paths = this._options.modulePaths;
const extensions = this._options.extensions;
const moduleDirectory = this._options.moduleDirectories;
return this._modulePathCache[from];}
_resolveStubModuleName(moduleName) {
const moduleNameMapper = this._options.moduleNameMapper;

@@ -226,11 +215,25 @@ if (moduleNameMapper) {

if (regex.test(moduleName)) {
return moduleName.replace(regex, mappedModuleName);}}}
moduleName = moduleName.replace(regex, mappedModuleName);
return this.getModule(moduleName) || Resolver.findNodeModule(
moduleName,
{
basedir: dirname,
browser: this._options.browser,
extensions,
moduleDirectory,
paths });
}
}
}
return null;
}
return null;}}
_supportsNativePlatform() {
return (this._options.platforms || []).indexOf(NATIVE_PLATFORM) !== -1;
}}
module.exports = Resolver;
{
"name": "jest-resolve",
"version": "14.1.0",
"version": "14.2.0-alpha.ca8bfb6e",
"repository": {

@@ -12,11 +12,6 @@ "type": "git",

"browser-resolve": "^1.11.2",
"jest-file-exists": "^14.0.0",
"jest-haste-map": "^14.1.0",
"jest-file-exists": "^14.2.0-alpha.ca8bfb6e",
"jest-haste-map": "^14.2.0-alpha.ca8bfb6e",
"resolve": "^1.1.6"
},
"jest": {
"rootDir": "./src",
"scriptPreprocessor": "../../babel-jest",
"testEnvironment": "node"
},
"scripts": {

@@ -23,0 +18,0 @@ "test": "../../packages/jest-cli/bin/jest.js"

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