fix: resolve package import wildcard trailers - #604
Open
cmpadden wants to merge 1 commit into
Open
Conversation
cmpadden
requested review from
a team,
icyJoseph,
ijjk and
styfle
as code owners
July 27, 2026 15:16
pi0x
pushed a commit
to cmpadden/nf3
that referenced
this pull request
Jul 27, 2026
Replace the `@vercel/nft` pnpm patch with a fallback resolver, so the fix does not have to be re-applied on every nft release (an exact-version `patchedDependencies` key hard-fails installs with ERR_PNPM_UNUSED_PATCH as soon as the version moves). nft exports its own resolver, so `nft.resolve` can wrap it and only fall back to exsolve — which implements the Node resolution algorithm — for specifiers nft throws on. exsolve had the same defect in its `imports` matching and fixes it in 1.1.1 (unjs/exsolve#56). This is purely additive: nft stays the primary resolver, so the fallback only ever turns a "Failed to resolve dependency" warning into a resolved file, and becomes a no-op once vercel/nft#604 lands. It also covers a case the patch did not: wildcard imports whose target is another package (`"#utils/*": "@fixture/nitro-utils/*"`). nft's wildcard branch only handles targets starting with `./`, so those stayed unresolved even with the patch applied. The fixture and test now assert both that and the original `"#*.js": "./runtime/*.js"` trailer case. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
package.jsonimport/export wildcard patterns that include a trailer, such as#*.jsimports-wildcardtrace fixture covering#internal/marker.jsmapped through#*.jsContext
NFT previously recognized wildcard keys only when they ended in
*. A valid import map such as:{ "imports": { "#*.js": "./dist/*.js" } }therefore failed to resolve
#internal/marker.js. Consumers such as Nitro/nf3 would trace the package entry point but omit the internal target, producing an incomplete deployment artifact that failed at runtime withERR_MODULE_NOT_FOUND.Related reproduction and downstream workaround:
Regression testing
The new
test/unit/imports-wildcardfixture imports#internal/marker.jsand expectsdist/internal/marker.jsin the trace.Before this change, both the cwd-based and root-based fixture variants failed because the marker file was absent. After the resolver change, both variants pass.
Validation performed:
pnpm buildpnpm prettier-checkpnpm exec jest test/unit.test.js --runInBand -t 'imports|exports-wildcard'pnpm exec jest --runInBand --silent— 1,475 tests passed