Turbopack: fix trailing-slash package root resolution (#100726)
### What?
Fix trailing-slash package-root resolution in Turbopack, including
dynamic CommonJS requests with an empty runtime suffix.
### Why?
The package-root result could be keyed as a bare package request even
when the request included a trailing slash. Dynamic module contexts then
lacked the slash-root key and threw `MODULE_NOT_FOUND` for a valid
package entry. Exact trailing-slash requests could also resolve the same
folder twice through overlapping root and relative-subpath paths.
### How?
Resolve matching package roots once while preserving distinct bare and
trailing-slash request keys. Only use relative-subpath resolution for
patterns that can match deeper paths, leaving package-exports handling
unchanged.
Add keyed Rust coverage for main/index fallback, exports and dynamic
patterns, plus a loader-free execution fixture that distinguishes the
package main from index and checks real and missing subpaths.
### Verification
- Confirmed the execution regression fails on the unfixed resolver and
passes with the correction.
- `cargo nextest run -p turbopack-tests --test execution -E
'test(resolving)'` — 33 fixtures passed.
- `cargo test -p turbopack-core --lib` — 198 passed; 2 existing ignored
benchmarks.
<!-- NEXT_JS_LLM -->
<!-- fleet 21b5a5ed-fae3-4261-8b72-44936c636deb -->
---------
Co-authored-by:
vercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com>
Showing
Please
register
or
sign in
to comment