jest-resolve
Advanced tools
Comparing version 13.3.0-alpha.g8b48d59 to 13.4.0-alpha.d2632006
@@ -22,3 +22,2 @@ /** | ||
const fs = require('fs'); | ||
const nodeModulesPaths = require('resolve/lib/node-modules-paths'); | ||
@@ -55,24 +54,2 @@ const path = require('path'); | ||
function compact(array) { | ||
const result = []; | ||
for (let i = 0; i < array.length; ++i) { | ||
const element = array[i]; | ||
if (element != null) { | ||
result.push(element);}} | ||
return result;} | ||
const getModuleNameMapper = config => { | ||
if (config.moduleNameMapper.length) { | ||
const moduleNameMapper = Object.create(null); | ||
config.moduleNameMapper.forEach( | ||
map => moduleNameMapper[map[1]] = new RegExp(map[0])); | ||
return moduleNameMapper;} | ||
return null;}; | ||
class Resolver { | ||
@@ -104,18 +81,2 @@ | ||
static create( | ||
config, | ||
moduleMap) | ||
{ | ||
return new Resolver(moduleMap, { | ||
browser: config.browser, | ||
defaultPlatform: config.haste.defaultPlatform, | ||
extensions: config.moduleFileExtensions.map(extension => '.' + extension), | ||
hasCoreModules: true, | ||
moduleDirectories: config.moduleDirectories, | ||
moduleNameMapper: getModuleNameMapper(config), | ||
modulePaths: config.modulePaths, | ||
platforms: config.haste.platforms });} | ||
static findNodeModule(path, options) { | ||
@@ -138,9 +99,2 @@ const paths = options.paths; | ||
static fileExists(filePath) { | ||
try { | ||
return fs.statSync(filePath).isFile();} | ||
catch (e) {} | ||
return false;} | ||
resolveModule( | ||
@@ -261,73 +215,2 @@ from, | ||
resolveDependencies( | ||
file, | ||
options) | ||
{ | ||
if (!this._moduleMap.files[file]) { | ||
return [];} | ||
return compact(this._moduleMap.files[file][H.DEPENDENCIES]. | ||
map(dependency => { | ||
if (this.isCoreModule(dependency)) { | ||
return null;} | ||
try { | ||
return this.resolveModule(file, dependency, options);} | ||
catch (e) {} | ||
return this.getMockModule(dependency) || null;}));} | ||
resolveInverseDependencies( | ||
paths, | ||
filter, | ||
options) | ||
{ | ||
const collectModules = (relatedPaths, moduleMap, changed) => { | ||
const visitedModules = new Set(); | ||
while (changed.size) { | ||
changed = new Set(moduleMap.filter(module => | ||
!visitedModules.has(module.file) && | ||
module.dependencies.some(dep => dep && changed.has(dep))). | ||
map(module => { | ||
const file = module.file; | ||
if (filter(file)) { | ||
relatedPaths.add(file);} | ||
visitedModules.add(file); | ||
return module.file;}));} | ||
return relatedPaths;}; | ||
if (!paths.size) { | ||
return [];} | ||
const relatedPaths = new Set(); | ||
const changed = new Set(); | ||
for (const path of paths) { | ||
if (Resolver.fileExists(path)) { | ||
const module = this._moduleMap.files[path]; | ||
if (module) { | ||
changed.add(path); | ||
if (filter(path)) { | ||
relatedPaths.add(path);}}}} | ||
const modules = []; | ||
for (const file in this._moduleMap.files) { | ||
modules.push({ | ||
file, | ||
dependencies: this.resolveDependencies(file, options) });} | ||
return Array.from(collectModules(relatedPaths, modules, changed));} | ||
_resolveStubModuleName(moduleName) { | ||
@@ -334,0 +217,0 @@ const moduleNameMapper = this._options.moduleNameMapper; |
{ | ||
"name": "jest-resolve", | ||
"version": "13.3.0-alpha.g8b48d59", | ||
"version": "13.4.0-alpha.d2632006", | ||
"repository": { | ||
@@ -12,3 +12,4 @@ "type": "git", | ||
"browser-resolve": "^1.11.2", | ||
"jest-haste-map": "^13.3.0-alpha.g8b48d59", | ||
"jest-file-exists": "^13.4.0-alpha.d2632006", | ||
"jest-haste-map": "^13.4.0-alpha.d2632006", | ||
"resolve": "^1.1.6" | ||
@@ -15,0 +16,0 @@ }, |
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
2
6191
4
136
+ Addedjest-file-exists@13.4.0-alpha.d2632006(transitive)
+ Addedjest-haste-map@13.4.0-alpha.d2632006(transitive)
- Removedjest-haste-map@13.3.0-alpha.g8b48d59(transitive)