Skip to content

chore(deps): migrate unrs-resolver to new oxc-resolver#479

Open
oceandrama wants to merge 3 commits intoimport-js:masterfrom
oceandrama:migrate-to-oxc-resolver
Open

chore(deps): migrate unrs-resolver to new oxc-resolver#479
oceandrama wants to merge 3 commits intoimport-js:masterfrom
oceandrama:migrate-to-oxc-resolver

Conversation

@oceandrama
Copy link
Copy Markdown

@oceandrama oceandrama commented Apr 7, 2026

Closes #470

Summary by CodeRabbit

  • Chores

    • Migrated resolver dependency from unrs-resolver to oxc-resolver and updated bundled resolvers
    • Updated eslint-import-context to v0.2.0
    • Added a changeset entry recording the dependency chore
  • Documentation

    • Updated resolver options docs and related links to reference the new resolver
  • Tests

    • Made a PnP-related unit test conditional to runtime PnP support

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 7, 2026

🦋 Changeset detected

Latest commit: e097b2a

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

This PR includes changesets to release 1 package
Name Type
eslint-import-resolver-typescript 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

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 7, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e0b71983-1229-4b20-8abc-534fe7c05899

📥 Commits

Reviewing files that changed from the base of the PR and between bd4091d and e097b2a.

📒 Files selected for processing (1)
  • tests/unit/unit.spec.ts

📝 Walkthrough

Walkthrough

Migrates resolver usage from unrs-resolver to oxc-resolver: updates dependencies, imports, option typing/normalization, resolver construction logic, README references, adds a changeset, and makes a test conditional on PnP presence.

Changes

Cohort / File(s) Summary
Changelog & Docs
.changeset/silly-beans-pretend.md, README.md
Added a changeset entry and replaced README references from unrs-resolver to oxc-resolver (anchors, headings, link targets, option descriptions).
Dependencies / Manifest
package.json
Removed unrs-resolver, added oxc-resolver@^11.19.1, bumped eslint-import-context to ^0.2.0; dependency list updated accordingly.
Core Resolver Logic
src/index.ts
Switched imports/calls from unrs-resolveroxc-resolver, renamed helper (unrsResolveoxcResolve), changed ResolverFactory construction to set only references: 'auto' and configFile, and adjusted logging and @types fallback to use the new resolver.
Options & Types
src/normalize-options.ts, src/types.ts
Swapped type imports to oxc-resolver; added a type guard to treat tsconfig as a Partial only when it's an object to avoid unsafe destructuring.
Tests
tests/unit/unit.spec.ts
Made the PnP-related test conditional by using it.skipIf(!process.versions.pnp) so it skips when PnP is not present.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

dependencies

Suggested reviewers

  • JounQin
  • SukkaW

Poem

🐰 I hopped through imports, swapped one for OXC,

Bundles refreshed, tsconfigs set tidy and neat,
A changeset tucked in for the patch-release key,
Tests skip when PnP's missing—soft landing, no feat.
🥕✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Out of Scope Changes check ❓ Inconclusive All changes are directly related to the migration from unrs-resolver to oxc-resolver; however, the PnP test skip may warrant clarification as to its necessity for the migration. Clarify whether the PnP test skip is necessary for the oxc-resolver migration or if it addresses a separate concern related to the new resolver.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title clearly and accurately describes the main change: migrating from unrs-resolver to oxc-resolver as a dependency chore.
Linked Issues check ✅ Passed The code changes comprehensively address the linked issue #470 requirement to migrate unrs-resolver to oxc-resolver across all relevant files.
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 Apr 7, 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.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Apr 7, 2026

Open in StackBlitz

npm i https://pkg.pr.new/eslint-import-resolver-typescript@479

commit: e097b2a

@socket-security
Copy link
Copy Markdown

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

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addednpm/​eslint-import-context@​0.2.0911009490100
Addednpm/​oxc-resolver@​11.19.19410010092100

View full report

@socket-security
Copy link
Copy Markdown

Warning

Review the following alerts detected in dependencies.

According to your organization's Security Policy, it is recommended to resolve "Warn" alerts. Learn more about Socket for GitHub.

Action Severity Alert  (click "▶" to expand/collapse)
Warn High
Publisher changed: npm eslint-import-context is now published by GitHub Actions

Author: [GitHub Actions](https://socket.dev/npm/user/GitHub Actions)

From: package.jsonnpm/eslint-import-context@0.2.0

ℹ Read more on: This package | This alert | What is unstable ownership?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Try to reduce the number of authors you depend on to reduce the risk to malicious actors gaining access to your supply chain. Packages should remove inactive collaborators with publishing rights from packages on npm.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/eslint-import-context@0.2.0. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

View full report

const resolver = createTypeScriptImportResolver()

it(
it.skipIf(!process.versions.pnp)(
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

pnp mode works only if process.versions.pnp is set, so tests may be skipped otherwise. I have the same behavior with the latest version of unrs-resolver since it has the same implementation, so I don't think this is an issue.

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.

Nope, the test starts another process, which doesn't depend on pnp on main thread.

Copy link
Copy Markdown
Author

@oceandrama oceandrama Apr 13, 2026

Choose a reason for hiding this comment

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

So, what's the root cause of the problem? It doesn't work with either the latest versions of unrs-resolver or oxc-resolver and I'm not sure if pnp is broken in both packages or tests are outdated?

Copy link
Copy Markdown

@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.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@package.json`:
- Line 76: The TypeScriptResolverOptions interface claims to pass through
resolver options from NapiResolveOptions but oxc-resolver no longer supports the
descriptionFiles option (previously in unrs-resolver); add a compatibility shim
that reads descriptionFiles from the resolver config and translates it into
equivalent behavior (e.g., implement logic in the resolver initialization code
or a new adapter function that honors descriptionFiles when resolving packages)
or mark this change as breaking by updating the package metadata and release
notes; reference TypeScriptResolverOptions, NapiResolveOptions,
descriptionFiles, and the resolver initialization/adapter function to locate
where to implement the shim or where to change the release type.

In `@src/normalize-options.ts`:
- Around line 35-36: The destructuring assumes tsconfig is an object but crashes
when tsconfig is null because typeof null === "object"; update the guard around
the destructuring (the usage of tsconfig and the line assigning
configFile/references) to ensure tsconfig is not null/undefined before treating
it as an object (e.g., check tsconfig != null && typeof tsconfig === 'object' or
tsconfig && typeof tsconfig === 'object'), then perform the destructure from
that safe value (or default to {}); adjust the let { configFile, references }:
Partial<TsconfigOptions> = ... assignment accordingly so { configFile,
references } never attempts to destructure null.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8a7ce38d-55b1-4313-b199-c4f60fff9dcc

📥 Commits

Reviewing files that changed from the base of the PR and between 76672ae and bd4091d.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (6)
  • .changeset/silly-beans-pretend.md
  • README.md
  • package.json
  • src/index.ts
  • src/normalize-options.ts
  • src/types.ts

"eslint-import-context": "^0.2.0",
"get-tsconfig": "^4.10.1",
"is-bun-module": "^2.0.0",
"oxc-resolver": "^11.19.1",
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify that the public surface still exposes passthrough resolver options
# and that there is no repo-local compatibility shim/coverage for descriptionFiles.
sed -n '1,10p' src/types.ts
sed -n '331,335p' README.md
rg -n -C2 '\bdescriptionFiles\b'

Repository: import-js/eslint-import-resolver-typescript

Length of output: 565


This dependency swap removes user-accessible resolver options.

The TypeScriptResolverOptions interface extends oxc-resolver's NapiResolveOptions and explicitly documents pass-through of additional options. However, oxc-resolver does not implement descriptionFiles, which was available in the previous unrs-resolver backend. No compatibility shim for this option exists in the codebase. This is a breaking change for users passing descriptionFiles through the resolver config. Either add a compatibility layer for dropped options or release as breaking instead of patch.

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

In `@package.json` at line 76, The TypeScriptResolverOptions interface claims to
pass through resolver options from NapiResolveOptions but oxc-resolver no longer
supports the descriptionFiles option (previously in unrs-resolver); add a
compatibility shim that reads descriptionFiles from the resolver config and
translates it into equivalent behavior (e.g., implement logic in the resolver
initialization code or a new adapter function that honors descriptionFiles when
resolving packages) or mark this change as breaking by updating the package
metadata and release notes; reference TypeScriptResolverOptions,
NapiResolveOptions, descriptionFiles, and the resolver initialization/adapter
function to locate where to implement the shim or where to change the release
type.

Comment on lines +35 to +36
let { configFile, references }: Partial<TsconfigOptions> =
typeof tsconfig === 'object' ? tsconfig : {}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Inspect the current guard for non-object `tsconfig` values.
sed -n '33,36p' src/normalize-options.ts

Repository: import-js/eslint-import-resolver-typescript

Length of output: 270


🏁 Script executed:

cat -n src/normalize-options.ts | head -60

Repository: import-js/eslint-import-resolver-typescript

Length of output: 2318


🏁 Script executed:

rg "tsconfig" src/normalize-options.ts -B 3 -A 3

Repository: import-js/eslint-import-resolver-typescript

Length of output: 868


🏁 Script executed:

# Check type definitions for the options parameter
rg "TsconfigOptions|NormalizeOptions" src/normalize-options.ts -B 2 -A 5

Repository: import-js/eslint-import-resolver-typescript

Length of output: 510


🏁 Script executed:

# Look for tests related to tsconfig null/undefined handling
fd "test|spec" -type f | head -10

Repository: import-js/eslint-import-resolver-typescript

Length of output: 257


🏁 Script executed:

fd -e ts -e tsx | xargs grep -l "TypeScriptResolverOptions" | head -5

Repository: import-js/eslint-import-resolver-typescript

Length of output: 137


🏁 Script executed:

rg "TypeScriptResolverOptions" src/ -A 15 --type ts

Repository: import-js/eslint-import-resolver-typescript

Length of output: 4451


🏁 Script executed:

# Look for test files
find . -name "*.test.*" -o -name "*.spec.*" -o -name "__tests__" -type d 2>/dev/null

Repository: import-js/eslint-import-resolver-typescript

Length of output: 179


🏁 Script executed:

cat -n src/types.ts

Repository: import-js/eslint-import-resolver-typescript

Length of output: 528


🏁 Script executed:

# Check if NapiResolveOptions is defined locally or imported
rg "NapiResolveOptions" src/types.ts -B 2 -A 2

Repository: import-js/eslint-import-resolver-typescript

Length of output: 320


🏁 Script executed:

# Look at test files to see how tsconfig is used
rg "tsconfig" tests/ -B 2 -A 2

Repository: import-js/eslint-import-resolver-typescript

Length of output: 6564


tsconfig: null still crashes this branch.

typeof null evaluates to "object" in JavaScript, so this guard still selects null and the destructuring throws before the {} fallback is used. If options contain { tsconfig: null }, the code crashes on line 36 when attempting to destructure the null value.

Proposed fix
-  let { configFile, references }: Partial<TsconfigOptions> =
-    typeof tsconfig === 'object' ? tsconfig : {}
+  let { configFile, references }: Partial<TsconfigOptions> =
+    tsconfig != null && typeof tsconfig === 'object' ? tsconfig : {}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
let { configFile, references }: Partial<TsconfigOptions> =
typeof tsconfig === 'object' ? tsconfig : {}
let { configFile, references }: Partial<TsconfigOptions> =
tsconfig != null && typeof tsconfig === 'object' ? tsconfig : {}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/normalize-options.ts` around lines 35 - 36, The destructuring assumes
tsconfig is an object but crashes when tsconfig is null because typeof null ===
"object"; update the guard around the destructuring (the usage of tsconfig and
the line assigning configFile/references) to ensure tsconfig is not
null/undefined before treating it as an object (e.g., check tsconfig != null &&
typeof tsconfig === 'object' or tsconfig && typeof tsconfig === 'object'), then
perform the destructure from that safe value (or default to {}); adjust the let
{ configFile, references }: Partial<TsconfigOptions> = ... assignment
accordingly so { configFile, references } never attempts to destructure null.

let { project, tsconfig, noWarnOnMultipleProjects } = (options ||= {})

let { configFile, references }: Partial<TsconfigOptions> = tsconfig ?? {}
let { configFile, references }: Partial<TsconfigOptions> =
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I'm not sure what to do with the auto option, so I decided to match the behavior with the undefined value

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Migrate unrs-resolver to new oxc-resolver

2 participants