Skip to content

Commit a6b21ae

Browse files
chore(release): new release
1 parent 077b391 commit a6b21ae

5 files changed

Lines changed: 44 additions & 49 deletions

File tree

.changeset/fix-exports-field-parent-fallback.md

Lines changed: 0 additions & 25 deletions
This file was deleted.

.changeset/fix-imports-field-no-chaining.md

Lines changed: 0 additions & 10 deletions
This file was deleted.

.changeset/fix-tsconfig-paths-missing-config.md

Lines changed: 0 additions & 13 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,48 @@
11
# enhanced-resolve
22

3+
## 5.20.2
4+
5+
### Patch Changes
6+
7+
- fix: prevent fallback to parent node_modules when exports field target file is not found (by [@xiaoxiaojx](https://github.com/xiaoxiaojx) in [#495](https://github.com/webpack/enhanced-resolve/pull/495))
8+
9+
When a package has an `exports` field that maps a request to a target file,
10+
but that target file does not exist on disk, enhanced-resolve was incorrectly
11+
falling back to search parent `node_modules` directories. This violated the
12+
Node.js ESM resolution spec, which requires resolution to fail with an error
13+
rather than continue searching up the directory tree.
14+
15+
This manifested in monorepos where the same package exists at multiple levels
16+
(e.g. `workspace/node_modules/pkg` and `root/node_modules/pkg`): if the
17+
workspace version's exports-mapped target was missing, the resolver would
18+
silently resolve to the root version instead.
19+
20+
Root cause: `ExportsFieldPlugin` was returning `null` on failure, which
21+
`Resolver.doResolve` converted to `undefined`, causing
22+
`ModulesInHierarchicalDirectoriesPlugin` to treat the lookup as "not found,
23+
try next directory" rather than a hard stop.
24+
25+
Fix: when the `exports` field is present and a match is found but no valid
26+
target file can be resolved, return an explicit error to stop directory
27+
traversal. Closes #399.
28+
29+
- Imports field spec deviation: non-relative targets (e.g. `"#a": "#b"`) (by [@xiaoxiaojx](https://github.com/xiaoxiaojx) in [#503](https://github.com/webpack/enhanced-resolve/pull/503))
30+
no longer re-enter imports resolution, aligning with the Node.js ESM spec
31+
where `PACKAGE_IMPORTS_RESOLVE` does not recursively resolve `#` specifiers.
32+
33+
Previously `{ "#a": "#b", "#b": "./the.js" }` would chain-resolve `#a` to
34+
`./the.js`; now it correctly fails, matching Node.js behavior.
35+
36+
- When `tsconfig: true` is used (default config file) and no `tsconfig.json` (by [@xiaoxiaojx](https://github.com/xiaoxiaojx) in [#502](https://github.com/webpack/enhanced-resolve/pull/502))
37+
exists, `TsconfigPathsPlugin` threw a file-not-found error that caused
38+
the entire resolve to fail — even for relative imports that don't need
39+
tsconfig path mappings.
40+
41+
Fix: when using the default config file and `tsconfig.json` is not found,
42+
the plugin now returns `null` and lets resolution continue normally.
43+
When the user provides an explicit path (string), a missing file still
44+
throws an error as expected.
45+
346
## 5.20.1
447

548
### Patch Changes

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "enhanced-resolve",
3-
"version": "5.20.1",
3+
"version": "5.20.2",
44
"description": "Offers a async require.resolve function. It's highly configurable.",
55
"homepage": "http://github.com/webpack/enhanced-resolve",
66
"repository": {

0 commit comments

Comments
 (0)