jest-resolve
Advanced tools
Comparing version 28.0.0-alpha.8 to 28.0.0-alpha.9
@@ -100,2 +100,30 @@ 'use strict'; | ||
moduleName = `${moduleName}/${segments.shift()}`; | ||
} // self-reference | ||
const closestPackageJson = (0, _fileWalkers.findClosestPackageJson)( | ||
options.basedir | ||
); | ||
if (closestPackageJson) { | ||
const pkg = (0, _fileWalkers.readPackageCached)(closestPackageJson); | ||
if (pkg.name === moduleName && pkg.exports) { | ||
const subpath = segments.join('/') || '.'; | ||
const resolved = (0, _resolve2.resolve)( | ||
pkg, | ||
subpath, | ||
createResolveOptions(options.conditions) | ||
); | ||
if (!resolved) { | ||
throw new Error( | ||
'`exports` exists, but no results - this is a bug in Jest. Please report an issue' | ||
); | ||
} | ||
return (0, _path().resolve)( | ||
(0, _path().dirname)(closestPackageJson), | ||
resolved | ||
); | ||
} | ||
} | ||
@@ -118,4 +146,2 @@ | ||
if (pkg.exports) { | ||
// we need to make sure resolve ignores `main` | ||
delete pkg.main; | ||
const subpath = segments.join('/') || '.'; | ||
@@ -126,10 +152,14 @@ const resolved = (0, _resolve2.resolve)( | ||
createResolveOptions(options.conditions) | ||
); // TODO: should we throw if not? | ||
); | ||
if (resolved) { | ||
return (0, _path().resolve)( | ||
(0, _path().dirname)(packageJsonPath), | ||
resolved | ||
if (!resolved) { | ||
throw new Error( | ||
'`exports` exists, but no results - this is a bug in Jest. Please report an issue' | ||
); | ||
} | ||
return (0, _path().resolve)( | ||
(0, _path().dirname)(packageJsonPath), | ||
resolved | ||
); | ||
} | ||
@@ -136,0 +166,0 @@ } |
@@ -280,3 +280,4 @@ 'use strict'; | ||
const resolveNodeModule = (name, throwIfNotFound = false) => { | ||
if (this.isCoreModule(name)) { | ||
// Only skip default resolver | ||
if (this.isCoreModule(name) && !this._options.resolver) { | ||
return name; | ||
@@ -355,3 +356,4 @@ } | ||
const resolveNodeModule = async (name, throwIfNotFound = false) => { | ||
if (this.isCoreModule(name)) { | ||
// Only skip default resolver | ||
if (this.isCoreModule(name) && !this._options.resolver) { | ||
return name; | ||
@@ -358,0 +360,0 @@ } |
{ | ||
"name": "jest-resolve", | ||
"version": "28.0.0-alpha.8", | ||
"version": "28.0.0-alpha.9", | ||
"repository": { | ||
@@ -22,6 +22,6 @@ "type": "git", | ||
"graceful-fs": "^4.2.9", | ||
"jest-haste-map": "^28.0.0-alpha.8", | ||
"jest-haste-map": "^28.0.0-alpha.9", | ||
"jest-pnp-resolver": "^1.2.2", | ||
"jest-util": "^28.0.0-alpha.8", | ||
"jest-validate": "^28.0.0-alpha.8", | ||
"jest-util": "^28.0.0-alpha.9", | ||
"jest-validate": "^28.0.0-alpha.9", | ||
"resolve": "^1.20.0", | ||
@@ -41,3 +41,3 @@ "resolve.exports": "^1.1.0", | ||
}, | ||
"gitHead": "d915e7df92b220dbe6e124585ba6459838a6c41c" | ||
"gitHead": "7c63f5981eb20d4b89a4c04f3675e0050d8d7887" | ||
} |
60568
1882
Updatedjest-util@^28.0.0-alpha.9