Skip to content

fix(resolver): patterns resolution#9462

Merged
ematipico merged 1 commit intomainfrom
fix/resolver-patterns
Mar 18, 2026
Merged

fix(resolver): patterns resolution#9462
ematipico merged 1 commit intomainfrom
fix/resolver-patterns

Conversation

@ematipico
Copy link
Member

Summary

Closes #9370

This PR has been vibe-coded with Claude.

Test Plan

Added new tests

Docs

N/A

@changeset-bot
Copy link

changeset-bot bot commented Mar 12, 2026

🦋 Changeset detected

Latest commit: 4c9e4af

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 13 packages
Name Type
@biomejs/biome Patch
@biomejs/cli-win32-x64 Patch
@biomejs/cli-win32-arm64 Patch
@biomejs/cli-darwin-x64 Patch
@biomejs/cli-darwin-arm64 Patch
@biomejs/cli-linux-x64 Patch
@biomejs/cli-linux-arm64 Patch
@biomejs/cli-linux-x64-musl Patch
@biomejs/cli-linux-arm64-musl Patch
@biomejs/wasm-web Patch
@biomejs/wasm-bundler Patch
@biomejs/wasm-nodejs Patch
@biomejs/backend-jsonrpc Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@ematipico ematipico requested review from a team March 12, 2026 16:30
@github-actions github-actions bot added the A-Resolver Area: resolver label Mar 12, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 12, 2026

Walkthrough

This pull request implements pattern specificity ordering for package exports resolution. It introduces a multi-stage resolution algorithm that evaluates exact matches first, then collects and sorts pattern keys by specificity (prioritising longer prefixes and suffixes) before attempting pattern matching. A new helper function compares pattern keys to determine resolution order. The resolver now treats null targets as NotFound. Changes include modifications to the resolution logic, a new test function with comprehensive assertions, and a corresponding changeset entry addressing issue #9370.

Suggested labels

A-Resolver

Suggested reviewers

  • arendjr
  • dyc3
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix(resolver): patterns resolution' directly reflects the main change—implementing pattern-based resolution logic to fix resolver exports specificity.
Description check ✅ Passed The description references the closed issue #9370 and mentions new tests were added, directly relating to the changeset which implements resolver pattern specificity fixes.
Linked Issues check ✅ Passed The PR implements exact-first plus pattern-based resolution with specificity sorting [#9370], addressing the inability to resolve package paths with multiple segments.
Out of Scope Changes check ✅ Passed All changes are directly scoped to resolver pattern resolution: algorithm updates, test fixtures, and test coverage for the specificity issue.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/resolver-patterns
📝 Coding Plan for PR comments
  • Generate coding plan

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
crates/biome_resolver/tests/spec_tests.rs (1)

750-813: Please add a trailer tie-break case.

This locks in the longer-prefix branch, but the new comparator in crates/biome_resolver/src/lib.rs (Lines 410-416) also prefers the longer suffix when prefixes tie. One extra case like ./features/*.json over ./features/* would pin that branch down too.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@crates/biome_resolver/tests/spec_tests.rs` around lines 750 - 813, Add a
trailer tie-break assertion to test_resolve_exports_pattern_specificity: after
the existing checks call resolve(...) with the module spec that includes the
.json trailer (e.g., "@kcconfigs/biome/features/svelte.json") and assert it
resolves to "{base_dir}/node_modules/@kcconfigs/biome/src/features/svelte.json"
using the same ResolveOptions and OsFileSystem setup; this pins the comparator
branch that prefers longer suffixes (ensure you use the same resolve(...)
invocation and Utf8PathBuf format as the other assertions).
.changeset/fix-resolver-exports-pattern-specificity.md (1)

5-5: Please make this changeset user-facing.

This currently reads more like resolver pseudocode than a release note. Please describe the user impact instead, e.g. that nested shared-config package paths resolve correctly again. As per coding guidelines, "Changeset descriptions must be written for end users (explain impact and what changed), not developers (avoid implementation details) in 1-3 sentences".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.changeset/fix-resolver-exports-pattern-specificity.md at line 5, Update the
changeset text for "Fixed [`#9370`]" to be user-facing: replace the technical
description with 1–3 sentences describing the impact (e.g., packages with nested
or overlapping export subpaths like "./features/*" now resolve correctly so
nested shared-config package paths no longer fail to import), and note that this
fixes resolution errors caused by less-specific patterns like "./*" matching
prematurely; keep wording concise and avoid implementation details.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In @.changeset/fix-resolver-exports-pattern-specificity.md:
- Line 5: Update the changeset text for "Fixed [`#9370`]" to be user-facing:
replace the technical description with 1–3 sentences describing the impact
(e.g., packages with nested or overlapping export subpaths like "./features/*"
now resolve correctly so nested shared-config package paths no longer fail to
import), and note that this fixes resolution errors caused by less-specific
patterns like "./*" matching prematurely; keep wording concise and avoid
implementation details.

In `@crates/biome_resolver/tests/spec_tests.rs`:
- Around line 750-813: Add a trailer tie-break assertion to
test_resolve_exports_pattern_specificity: after the existing checks call
resolve(...) with the module spec that includes the .json trailer (e.g.,
"@kcconfigs/biome/features/svelte.json") and assert it resolves to
"{base_dir}/node_modules/@kcconfigs/biome/src/features/svelte.json" using the
same ResolveOptions and OsFileSystem setup; this pins the comparator branch that
prefers longer suffixes (ensure you use the same resolve(...) invocation and
Utf8PathBuf format as the other assertions).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 987d5003-292b-4714-91a9-b72a42c72125

📥 Commits

Reviewing files that changed from the base of the PR and between b71292c and 4c9e4af.

⛔ Files ignored due to path filters (4)
  • crates/biome_resolver/tests/fixtures/resolver_cases_8/node_modules/@kcconfigs/biome/package.json is excluded by !**/node_modules/** and included by **
  • crates/biome_resolver/tests/fixtures/resolver_cases_8/node_modules/@kcconfigs/biome/src/features/private-internal/secret.json is excluded by !**/node_modules/** and included by **
  • crates/biome_resolver/tests/fixtures/resolver_cases_8/node_modules/@kcconfigs/biome/src/features/svelte.json is excluded by !**/node_modules/** and included by **
  • crates/biome_resolver/tests/fixtures/resolver_cases_8/node_modules/@kcconfigs/biome/src/presets/default.json is excluded by !**/node_modules/** and included by **
📒 Files selected for processing (4)
  • .changeset/fix-resolver-exports-pattern-specificity.md
  • crates/biome_resolver/src/lib.rs
  • crates/biome_resolver/tests/fixtures/resolver_cases_8/package.json
  • crates/biome_resolver/tests/spec_tests.rs

@ematipico ematipico merged commit c23272c into main Mar 18, 2026
13 checks passed
@ematipico ematipico deleted the fix/resolver-patterns branch March 18, 2026 07:53
@github-actions github-actions bot mentioned this pull request Mar 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Resolver Area: resolver

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🐛 Cannot extends package when more than 2 slash (/)

1 participant