Skip to content

chore(deps): migrate from unrs-resolver to oxc-resolver#445

Open
bjnewman wants to merge 2 commits into
un-ts:masterfrom
bjnewman:chore/migrate-to-oxc-resolver
Open

chore(deps): migrate from unrs-resolver to oxc-resolver#445
bjnewman wants to merge 2 commits into
un-ts:masterfrom
bjnewman:chore/migrate-to-oxc-resolver

Conversation

@bjnewman
Copy link
Copy Markdown

@bjnewman bjnewman commented Jan 21, 2026

Summary

Resolves #412.

This PR migrates eslint-plugin-import-x from unrs-resolver to oxc-resolver, aligning with eslint-import-context's recent migration (v0.2.0).

Changes

  • Replace unrs-resolver with oxc-resolver@^11.0.0
  • Update eslint-import-context to ^0.2.0
  • Update documentation references

Behavioral Difference & Test Update

One test case was updated to accommodate a behavioral difference between resolvers.

Background

The original test came from eslint-plugin-import. It verifies that './bar' and 'bar' (with paths setting) are detected as duplicates by resolving to the same file.

Resolution Behaviors

Resolver Used By bar resolves to Spec
browserify/resolve eslint-plugin-import bar.js Node.js
unrs-resolver eslint-plugin-import-x (old) bar.js Node.js
oxc-resolver eslint-plugin-import-x (new) bar/index.js webpack

The test fixtures include both bar.js and bar/index.js with different content.

Why oxc-resolver Differs

This is intentional per oxc-resolver's design. From their source code:

"Only load the file if it is targeting a X/sub/dir. Otherwise just load the directory. No modern package manager creates node_modules/X.js."

oxc-resolver follows webpack's enhanced-resolve behavior rather than Node.js's algorithm. For bare specifiers like require('bar'), it assumes you want a directory (package) rather than a lone file.

Our Solution

The test was updated to use deprecated instead of bar:

  • deprecated.js exists without a conflicting deprecated/ directory
  • The test still verifies duplicate detection works correctly with paths
  • Other tests depending on bar/index.js remain unaffected

We acknowledge this is a nuanced difference and are very open to feedback if the maintainers prefer an alternate approach ( (like adding a resolver option, keeping the original test and accepting the behavior change, or another solution), we're happy to adjust.

Test Plan

  • yarn build succeeds
  • All 3015 tests pass
  • Pre-commit hooks pass (eslint, tsc)

Important

Migrate from unrs-resolver to oxc-resolver, updating dependencies, documentation, and tests to reflect the new resolver's behavior.

  • Dependencies:
    • Replace unrs-resolver with oxc-resolver@^11.0.0 in package.json.
    • Update eslint-import-context to ^0.2.0 in package.json.
  • Documentation:
    • Update references from unrs-resolver to oxc-resolver in README.md and resolvers/README.md.
  • Tests:
    • Update test case in test/rules/no-duplicates.spec.ts to use deprecated instead of bar to accommodate oxc-resolver behavior.
  • Code:
    • Modify src/node-resolver.ts to use oxc-resolver instead of unrs-resolver.

This description was created by Ellipsis for a2f0af3. You can customize this summary. It will automatically update as commits are pushed.

Summary by CodeRabbit

  • Chores

    • Switched resolver implementation reference from unrs-resolver to oxc-resolver
    • Bumped eslint-import-context to v0.2.0 and updated dependencies
  • Documentation

    • Updated README and resolver docs to reflect the resolver name change
  • Tests

    • Adjusted an import test case and its expected autofix output to use a trailing slash

Review Change Stack

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Jan 21, 2026

⚠️ No Changeset found

Latest commit: 86b75c0

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 21, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This PR replaces unrs-resolver with oxc-resolver: update imports in src/node-resolver.ts, change dependencies in package.json (add oxc-resolver, remove unrs-resolver, bump eslint-import-context), update README docs/examples, and adjust one test import specifier.

Changes

Resolver Migration from unrs-resolver to oxc-resolver

Layer / File(s) Summary
Core resolver import and dependency swap
src/node-resolver.ts, package.json
ResolverFactory and NapiResolveOptions imports switch from unrs-resolver to oxc-resolver; unrs-resolver dependency removed, oxc-resolver added, and eslint-import-context bumped to ^0.2.0.
Test case specifier update
test/rules/no-duplicates.spec.ts
Invalid test case import specifier changed from ./bar to ./bar/; expected autofix output updated and expected error count remains 2.
Documentation references
README.md, resolvers/README.md
Top-level README and resolvers README updated to reference oxc-resolver instead of unrs-resolver in differences, examples, imports/types, and link definitions.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested labels

dependencies

Suggested reviewers

  • JounQin

Poem

🐰 I hopped through modules, swapped a name,
Docs and packages played the same game.
Tests got tidy, imports align,
From unrs to oxc we now define.
A tiny hop, a cleaner frame.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title accurately summarizes the main change: migrating from unrs-resolver to oxc-resolver, which is the primary objective across all modified files.
Linked Issues check ✅ Passed All coding objectives from issue #412 are met: unrs-resolver replaced with oxc-resolver@^11.0.0, eslint-import-context updated to ^0.2.0, documentation updated, src/node-resolver.ts modified, and tests adapted for resolver behavior differences.
Out of Scope Changes check ✅ Passed All changes are directly related to the migration objective. The eslint-import-context version bump to ^0.2.0 and test fixture change are necessary dependencies and adaptations of the migration scope.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@codesandbox-ci
Copy link
Copy Markdown

codesandbox-ci Bot commented Jan 21, 2026

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Copy link
Copy Markdown

@ellipsis-dev ellipsis-dev Bot left a comment

Choose a reason for hiding this comment

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

Important

Looks good to me! 👍

Reviewed everything up to a2f0af3 in 57 seconds. Click for details.
  • Reviewed 100 lines of code in 5 files
  • Skipped 1 files when reviewing.
  • Skipped posting 5 draft comments. View those below.
  • Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. README.md:80
  • Draft comment:
    Updated reference to oxc-resolver is correct and clearly explains the behavioral differences.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50% None
2. package.json:85
  • Draft comment:
    Dependency updates are consistent: unrs-resolver removed, oxc-resolver added, and eslint-import-context bumped to ^0.2.0.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50% None
3. resolvers/README.md:107
  • Draft comment:
    Documentation sample now correctly uses oxc-resolver in the wrapper example.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50% None
4. src/node-resolver.ts:4
  • Draft comment:
    Migration of the resolver import to oxc-resolver is implemented correctly.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50% None
5. test/rules/no-duplicates.spec.ts:90
  • Draft comment:
    Test case updated to use './deprecated' instead of './bar' to match the new resolver behavior.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50% None

Workflow ID: wflow_wuPEGseKsLp4WXy3

You can customize Ellipsis by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.

@socket-security
Copy link
Copy Markdown

socket-security Bot commented Jan 21, 2026

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedeslint-import-context@​0.2.0911009490100

View full report

@pumano
Copy link
Copy Markdown

pumano commented Jan 30, 2026

@JounQin could you please check and review it?

@JounQin
Copy link
Copy Markdown
Member

JounQin commented Feb 3, 2026

oxc-resolver drops postinstall support which will break legacy npm projects, and the PR mentioned, some behavor changed, so the migration can only happen in the next major version maybe.

Comment thread test/rules/no-duplicates.spec.ts Outdated
Comment on lines +90 to +91
code: "import { x } from './deprecated'; import { y } from 'deprecated';",
output: "import { x, y } from './deprecated'; ",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Any reason why this unit test is modified?

Copy link
Copy Markdown
Member

@JounQin JounQin May 18, 2026

Choose a reason for hiding this comment

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

Related to oxc-project/oxc-resolver#839.

Since node_modules/bar.js is not used by modern package managers, I'd ignore this case, WDYT? @SukkaW

Copy link
Copy Markdown
Collaborator

@SukkaW SukkaW left a comment

Choose a reason for hiding this comment

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

The changes themselves (besides oxc-resolver potential breaking) LGTM overall, small nitpicking on modified tests. I will approve the action to see if all tests actually passed.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Feb 5, 2026

Open in StackBlitz

npm i https://pkg.pr.new/eslint-plugin-import-x@445

commit: 86b75c0

@bjnewman
Copy link
Copy Markdown
Author

bjnewman commented Feb 9, 2026

This change is related — the test verifies that two import paths resolving to the same file are flagged as duplicates. My understanding is that the test fixtures have both bar.js and bar/index.js, and with unrs-resolver both './bar' and 'bar' resolved to bar.js. With oxc-resolver, 'bar' appears to resolve to bar/index.js instead, so the two paths are no longer the same file and the test would incorrectly pass. I switched to deprecated because only deprecated.js exists (no deprecated/ directory), so both import paths still resolve to the same file and the test remains valid. Happy to take a different approach if I'm off base here.

@JounQin JounQin force-pushed the chore/migrate-to-oxc-resolver branch from a2f0af3 to e123a57 Compare May 18, 2026 06:08
@codacy-production
Copy link
Copy Markdown

codacy-production Bot commented May 18, 2026

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity · 0 duplication

Metric Results
Complexity 0
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@JounQin JounQin force-pushed the chore/migrate-to-oxc-resolver branch 2 times, most recently from 173557d to da7f4e0 Compare May 18, 2026 06:28
Resolves un-ts#412.

- Replace unrs-resolver with oxc-resolver ^11.0.0
- Update eslint-import-context to ^0.2.0
- Update documentation references
- Adjust test for oxc-resolver's directory-first resolution
@JounQin JounQin force-pushed the chore/migrate-to-oxc-resolver branch from da7f4e0 to 6a00aa5 Compare May 18, 2026 06:36
@JounQin JounQin force-pushed the chore/migrate-to-oxc-resolver branch from a8dec38 to 86b75c0 Compare May 18, 2026 07:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Migrate unrs-resolver to new oxc-resolver

4 participants