Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: old import-x/resolve options now use new built-in node resolver #272

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

SukkaW
Copy link
Collaborator

@SukkaW SukkaW commented Mar 30, 2025

Migrate the legacy import-x/resolve options to use our new built-in node resolver.

The import-x/resolve is a legacy option that is not even documented anymore (neither in the eslint-plugin-import nor eslint-plugin-import-x).

Summary by CodeRabbit

  • New Features
    • Enhanced module resolution configuration with additional options for controlling module search behavior.
  • Refactor
    • Streamlined legacy resolver handling to prioritize improved settings while retaining backward compatibility.
    • Introduced a dedicated node resolver instance for managing legacy settings.
  • Chores
    • Re-added the dependency "eslint-import-resolver-node": "^0.3.9" in the package configuration.

Copy link

changeset-bot bot commented Mar 30, 2025

⚠️ No Changeset found

Latest commit: d21b8d8

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

@SukkaW SukkaW requested review from JounQin and Copilot March 30, 2025 07:39
Copy link

coderabbitai bot commented Mar 30, 2025

Walkthrough

This pull request restructures the node resolver configuration by replacing NodeResolverOptions with a new LegacyNodeResolverOptions. The new type includes additional properties—such as includeCoreModules and preserveSymlinks—and updates the type of moduleDirectory` from an array to a string. Several properties are now marked as placeholders (noop). Additionally, type references in legacy resolver settings have been updated to use the new type, and a new resolver instance is conditionally created in the module resolution flow when legacy settings are detected.

Changes

File(s) Change Summary
src/types.ts
src/utils/legacy-resolver-settings.ts
Replaced NodeResolverOptions with LegacyNodeResolverOptions; added properties (includeCoreModules, preserveSymlinks, noop placeholders) and updated type references in both ImportSettings and legacy resolver type definitions.
src/utils/resolve.ts Introduced a new variable fallbackLegacyNodeResolver and modified the control flow to first use the new resolver instance for import-x/resolve settings, falling back to legacy resolver logic when necessary.
package.json Removed and re-added the dependency "eslint-import-resolver-node": "^0.3.9" in the dependencies section.

Possibly related PRs

Suggested reviewers

  • JounQin

Poem

I'm a rabbit coding under moonlit beams,
Hopping through types and legacy dreams.
New options bloom in a neat array,
With placeholders and changes leading the way.
I nibble on code, so spry and keen—
Celebrating changes with a happy, twitching scene!
🥕✨

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

src/utils/resolve.ts

Oops! Something went wrong! :(

ESLint: 9.23.0

Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/lib/index.js' imported from /eslint.config.js
at finalizeResolution (node:internal/modules/esm/resolve:257:11)
at moduleResolve (node:internal/modules/esm/resolve:914:10)
at defaultResolve (node:internal/modules/esm/resolve:1038:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:557:12)
at ModuleLoader.resolve (node:internal/modules/esm/loader:525:25)
at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:246:38)
at ModuleJob._link (node:internal/modules/esm/module_job:126:49)
(node:3316) ExperimentalWarning: Importing JSON modules is an experimental feature and might change at any time
(Use node --trace-warnings ... to show where the warning was created)

src/types.ts

Oops! Something went wrong! :(

ESLint: 9.23.0

Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/lib/index.js' imported from /eslint.config.js
at finalizeResolution (node:internal/modules/esm/resolve:257:11)
at moduleResolve (node:internal/modules/esm/resolve:914:10)
at defaultResolve (node:internal/modules/esm/resolve:1038:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:557:12)
at ModuleLoader.resolve (node:internal/modules/esm/loader:525:25)
at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:246:38)
at ModuleJob._link (node:internal/modules/esm/module_job:126:49)
(node:3315) ExperimentalWarning: Importing JSON modules is an experimental feature and might change at any time
(Use node --trace-warnings ... to show where the warning was created)

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR migrates the legacy "import-x/resolve" option to use the new built-in Node resolver, improving consistency and removing unsupported legacy options.

  • Updates the resolution logic in src/utils/resolve.ts to utilize the new node resolver for backward compatibility.
  • Renames type definitions from NodeResolverOptions to LegacyNodeResolverOptions in both src/utils/legacy-resolver-settings.ts and src/types.ts.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/utils/resolve.ts Implements new resolution logic using createNodeResolver and updates branch logic for legacy settings.
src/utils/legacy-resolver-settings.ts Updates type imports to use LegacyNodeResolverOptions for legacy resolver configurations.
src/types.ts Renames NodeResolverOptions to LegacyNodeResolverOptions and updates associated documentation.
Comments suppressed due to low confidence (2)

src/utils/resolve.ts:107

  • [nitpick] The variable name 'nodeResolverInstanceForLegacyNodeResolverSettings' is overly verbose. Consider renaming it to 'legacyNodeResolver' or a similar concise identifier.
let nodeResolverInstanceForLegacyNodeResolverSettings: NewResolver | null = null

src/utils/resolve.ts:168

  • The new branch for handling legacy 'import-x/resolve' options should be accompanied by test cases to validate its behavior. Consider adding tests that cover both successful and unsuccessful resolution scenarios.
else if ( Object.prototype.hasOwnProperty.call(settings, 'import-x/resolve') && settings['import-x/resolve'] ) {

Copy link

codesandbox-ci bot commented Mar 30, 2025

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

pkg-pr-new bot commented Mar 30, 2025

Open in StackBlitz

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

commit: d21b8d8

src/types.ts Outdated
Comment on lines 45 to 48
/** Noop now, Previously a directory to begin resolving from */
basedir?: string
/** Noop now. Previously for require.paths array to, it is now noop */
paths?: string[]
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Both the basedir option and the paths option are not supported by unrs-resolver. Is it possible to implement this, or should we just make it as noop?

This affects many unit tests IMHO.

Copy link
Member

@JounQin JounQin Mar 30, 2025

Choose a reason for hiding this comment

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

image

I don't think basedir is exposed.

image

modules is the replacement of paths.

Copy link
Member

Choose a reason for hiding this comment

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

IMO, we can mark eslint-import-resolver-node as optional peer dependency, if the user passed options we didn't support, we use original eslint-import-resolver-node, otherwise, use our internal node resolver instead.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

modules is the replacement of paths.

But resolve also has moduleDirectory. IMHO the paths here aligns with require.paths.

Copy link
Collaborator Author

@SukkaW SukkaW Mar 30, 2025

Choose a reason for hiding this comment

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

IMO, we can mark eslint-import-resolver-node as optional peer dependency, if the user passed options we didn't support, we use original eslint-import-resolver-node, otherwise, use our internal node resolver instead.

The idea is that almost nobody uses import/resolve:

https://github.com/search?q=%2F%5B%27%22%5Dimport%5C%2Fresolve%5B%27%22%5D%2F&type=code

And only our unit tests use import-x/resolve:

https://github.com/search?q=%2F%5B%27%22%5Dimport-x%5C%2Fresolve%5B%27%22%5D%2F&type=code

This is because the import/resolve has been "deprecated" long ago and has never been documented since. But this is only part that requires eslint-import-resolver-node.

So we can probably include this as a semi-breaking change and drop eslint-import-resovler-node completely without a non-major version bump.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

IMHO, let's just remove it first, and probably no eslint-plugin-import-x users will be affected.

Implementing fallback will result in inconsistent behaviors (sometimes use eslint-import-resolver-node, sometimes use unrs-resolver), there might be this:

// eslint.config.js
export default [
  { settings: { 'import-x/resolve': legacy } },
  { settings: { 'import-x/resolve': lessLegacy } }
];

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

But we will still need to implement paths, otherwise the unit tests will fail.

Copy link
Member

Choose a reason for hiding this comment

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

modules can not cover paths test cases? Then I'd like to still mark resolver-node as optional peer.

Copy link
Member

Choose a reason for hiding this comment

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

opts.paths - require.paths array to use if nothing is found on the normal node_modules recursive walk (probably don't use this)

I think paths behavior can be mocked when found: false and do another try through modules: paths?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't get it. I just tried adding paths to modules. The tests are still failing.

SukkaW and others added 3 commits March 30, 2025 21:02
@SukkaW SukkaW force-pushed the replace-eslint-import-resolver-node branch from 7dab322 to 2a66b0a Compare March 30, 2025 13:02
Copy link

@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: 8

🧹 Nitpick comments (2)
src/utils/resolve.ts (1)

114-114: Variable initialization concern

This variable is declared but only conditionally initialized. Consider using let nodeResolverInstanceForLegacyNodeResolverSettings: NewResolver | undefined to make nullability explicit.

-let nodeResolverInstanceForLegacyNodeResolverSettings: NewResolver
+let nodeResolverInstanceForLegacyNodeResolverSettings: NewResolver | undefined
🧰 Tools
🪛 GitHub Actions: Publish Any Commit

[error] Circular dependency: src/utils/resolve.ts -> src/utils/legacy-resolver-settings.ts -> src/utils/resolve.ts

src/types.ts (1)

45-48: Document the reason for noop properties

Properties marked as "Noop now" should have a clearer explanation of why they've been deprecated or marked as noop, especially since they were previously functional as indicated by the comments.

-  /** Noop now, Previously a directory to begin resolving from */
+  /** Noop now. Previously a directory to begin resolving from. These legacy options are maintained for backward compatibility but no longer affect resolution. */
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7dab322 and 2a66b0a.

📒 Files selected for processing (3)
  • src/types.ts (2 hunks)
  • src/utils/legacy-resolver-settings.ts (3 hunks)
  • src/utils/resolve.ts (3 hunks)
🧰 Additional context used
🧬 Code Definitions (1)
src/utils/resolve.ts (2)
src/types.ts (1)
  • NewResolver (86-91)
src/utils/legacy-resolver-settings.ts (2)
  • normalizeConfigResolvers (103-155)
  • resolveWithLegacyResolver (75-101)
🪛 GitHub Check: Lint and Test with Node.js 20 and ESLint 8.56 on windows-latest
src/types.ts

[failure] 124-124:
Cannot find name 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/legacy-resolver-settings.ts

[failure] 10-10:
'"../types.js"' has no exported member named 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/resolve.ts

[failure] 7-7:
Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean '../node-resolver.js'?

🪛 GitHub Check: Lint and Test with Node.js 22 and ESLint 8 on windows-latest
src/types.ts

[failure] 124-124:
Cannot find name 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/legacy-resolver-settings.ts

[failure] 10-10:
'"../types.js"' has no exported member named 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/resolve.ts

[failure] 7-7:
Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean '../node-resolver.js'?

🪛 GitHub Check: Lint and Test with Node.js 22 and ESLint 9 on windows-latest
src/types.ts

[failure] 124-124:
Cannot find name 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/legacy-resolver-settings.ts

[failure] 10-10:
'"../types.js"' has no exported member named 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/resolve.ts

[failure] 7-7:
Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean '../node-resolver.js'?

🪛 GitHub Check: Lint and Test with Node.js 22 and ESLint 8.56 on windows-latest
src/types.ts

[failure] 124-124:
Cannot find name 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/legacy-resolver-settings.ts

[failure] 10-10:
'"../types.js"' has no exported member named 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/resolve.ts

[failure] 7-7:
Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean '../node-resolver.js'?

🪛 GitHub Check: Lint and Test with Node.js 22 and ESLint 9 on macos-latest
src/types.ts

[failure] 124-124:
Cannot find name 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/legacy-resolver-settings.ts

[failure] 10-10:
'"../types.js"' has no exported member named 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/resolve.ts

[failure] 7-7:
Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean '../node-resolver.js'?

🪛 GitHub Check: Lint and Test with Node.js 18 and ESLint 8 on windows-latest
src/types.ts

[failure] 124-124:
Cannot find name 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/legacy-resolver-settings.ts

[failure] 10-10:
'"../types.js"' has no exported member named 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/resolve.ts

[failure] 7-7:
Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean '../node-resolver.js'?

🪛 GitHub Check: Lint and Test with Node.js 18 and ESLint 9 on windows-latest
src/types.ts

[failure] 124-124:
Cannot find name 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/legacy-resolver-settings.ts

[failure] 10-10:
'"../types.js"' has no exported member named 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/resolve.ts

[failure] 7-7:
Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean '../node-resolver.js'?

🪛 GitHub Check: Lint and Test with Node.js 20 and ESLint 9 on windows-latest
src/types.ts

[failure] 124-124:
Cannot find name 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/legacy-resolver-settings.ts

[failure] 10-10:
'"../types.js"' has no exported member named 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/resolve.ts

[failure] 7-7:
Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean '../node-resolver.js'?

🪛 GitHub Check: Lint and Test with Node.js 20 and ESLint 8.56 on ubuntu-latest
src/types.ts

[failure] 124-124:
Cannot find name 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/legacy-resolver-settings.ts

[failure] 10-10:
'"../types.js"' has no exported member named 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/resolve.ts

[failure] 7-7:
Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean '../node-resolver.js'?

🪛 GitHub Check: Lint and Test with Node.js 18 and ESLint 8.56 on macos-latest
src/types.ts

[failure] 124-124:
Cannot find name 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/legacy-resolver-settings.ts

[failure] 10-10:
'"../types.js"' has no exported member named 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/resolve.ts

[failure] 7-7:
Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean '../node-resolver.js'?

🪛 GitHub Check: Lint and Test with Node.js 18 and ESLint 8.56 on windows-latest
src/types.ts

[failure] 124-124:
Cannot find name 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/legacy-resolver-settings.ts

[failure] 10-10:
'"../types.js"' has no exported member named 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/resolve.ts

[failure] 7-7:
Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean '../node-resolver.js'?

🪛 GitHub Check: Lint and Test with Node.js 22 and ESLint 8 on ubuntu-latest
src/types.ts

[failure] 124-124:
Cannot find name 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/legacy-resolver-settings.ts

[failure] 10-10:
'"../types.js"' has no exported member named 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/resolve.ts

[failure] 7-7:
Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean '../node-resolver.js'?

🪛 GitHub Check: Lint and Test with Node.js 20 and ESLint 8 on windows-latest
src/types.ts

[failure] 124-124:
Cannot find name 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/legacy-resolver-settings.ts

[failure] 10-10:
'"../types.js"' has no exported member named 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/resolve.ts

[failure] 7-7:
Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean '../node-resolver.js'?

🪛 GitHub Check: Lint and Test with Node.js 22 and ESLint 9 on ubuntu-latest
src/types.ts

[failure] 124-124:
Cannot find name 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/legacy-resolver-settings.ts

[failure] 10-10:
'"../types.js"' has no exported member named 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/resolve.ts

[failure] 7-7:
Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean '../node-resolver.js'?

🪛 GitHub Check: Lint and Test with Node.js 18 and ESLint 8 on ubuntu-latest
src/types.ts

[failure] 124-124:
Cannot find name 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/legacy-resolver-settings.ts

[failure] 10-10:
'"../types.js"' has no exported member named 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/resolve.ts

[failure] 7-7:
Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean '../node-resolver.js'?

🪛 GitHub Check: Lint and Test with Node.js 20 and ESLint 9 on ubuntu-latest
src/types.ts

[failure] 124-124:
Cannot find name 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/legacy-resolver-settings.ts

[failure] 10-10:
'"../types.js"' has no exported member named 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/resolve.ts

[failure] 7-7:
Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean '../node-resolver.js'?

🪛 GitHub Check: Lint and Test with Node.js 20 and ESLint 8 on ubuntu-latest
src/types.ts

[failure] 124-124:
Cannot find name 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/legacy-resolver-settings.ts

[failure] 10-10:
'"../types.js"' has no exported member named 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/resolve.ts

[failure] 7-7:
Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean '../node-resolver.js'?

🪛 GitHub Check: Lint and Test with Node.js 18 and ESLint 9 on ubuntu-latest
src/types.ts

[failure] 124-124:
Cannot find name 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/legacy-resolver-settings.ts

[failure] 10-10:
'"../types.js"' has no exported member named 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/resolve.ts

[failure] 7-7:
Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean '../node-resolver.js'?

🪛 GitHub Check: Lint and Test with Node.js 18 and ESLint 8.56 on ubuntu-latest
src/types.ts

[failure] 124-124:
Cannot find name 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/legacy-resolver-settings.ts

[failure] 10-10:
'"../types.js"' has no exported member named 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/resolve.ts

[failure] 7-7:
Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean '../node-resolver.js'?

🪛 GitHub Check: Lint and Test with Node.js 22 and ESLint 8.56 on ubuntu-latest
src/types.ts

[failure] 124-124:
Cannot find name 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/legacy-resolver-settings.ts

[failure] 10-10:
'"../types.js"' has no exported member named 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/resolve.ts

[failure] 7-7:
Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean '../node-resolver.js'?

🪛 GitHub Check: Lint and Test with Node.js 20 and ESLint 8.56 on macos-latest
src/types.ts

[failure] 124-124:
Cannot find name 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/legacy-resolver-settings.ts

[failure] 10-10:
'"../types.js"' has no exported member named 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/resolve.ts

[failure] 7-7:
Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean '../node-resolver.js'?

🪛 GitHub Check: Lint and Test with Node.js 18 and ESLint 9 on macos-latest
src/types.ts

[failure] 124-124:
Cannot find name 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/legacy-resolver-settings.ts

[failure] 10-10:
'"../types.js"' has no exported member named 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/resolve.ts

[failure] 7-7:
Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean '../node-resolver.js'?

🪛 GitHub Check: Lint and Test with Node.js 20 and ESLint 8 on macos-latest
src/types.ts

[failure] 124-124:
Cannot find name 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/legacy-resolver-settings.ts

[failure] 10-10:
'"../types.js"' has no exported member named 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/resolve.ts

[failure] 7-7:
Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean '../node-resolver.js'?

🪛 GitHub Check: Lint and Test with Node.js 22 and ESLint 8 on macos-latest
src/types.ts

[failure] 124-124:
Cannot find name 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/legacy-resolver-settings.ts

[failure] 10-10:
'"../types.js"' has no exported member named 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/resolve.ts

[failure] 7-7:
Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean '../node-resolver.js'?

🪛 GitHub Check: Lint and Test with Node.js 22 and ESLint 8.56 on macos-latest
src/types.ts

[failure] 124-124:
Cannot find name 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/legacy-resolver-settings.ts

[failure] 10-10:
'"../types.js"' has no exported member named 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/resolve.ts

[failure] 7-7:
Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean '../node-resolver.js'?

🪛 GitHub Check: Lint and Test with Node.js 20 and ESLint 9 on macos-latest
src/types.ts

[failure] 124-124:
Cannot find name 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/legacy-resolver-settings.ts

[failure] 10-10:
'"../types.js"' has no exported member named 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/resolve.ts

[failure] 7-7:
Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean '../node-resolver.js'?

🪛 GitHub Check: Lint and Test with Node.js 18 and ESLint 8 on macos-latest
src/types.ts

[failure] 124-124:
Cannot find name 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/legacy-resolver-settings.ts

[failure] 10-10:
'"../types.js"' has no exported member named 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/resolve.ts

[failure] 7-7:
Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean '../node-resolver.js'?

🪛 GitHub Check: publish
src/types.ts

[failure] 124-124:
Cannot find name 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/legacy-resolver-settings.ts

[failure] 10-10:
'"../types.js"' has no exported member named 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/resolve.ts

[failure] 7-7:
Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean '../node-resolver.js'?

🪛 GitHub Actions: Publish Any Commit
src/types.ts

[error] 124-124: error TS2552: Cannot find name 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/resolve.ts

[warning] 24-24: "import.meta" is not available in the configured target environment ("es2015") and will be empty [empty-import-meta]


[error] Circular dependency: src/utils/resolve.ts -> src/utils/legacy-resolver-settings.ts -> src/utils/resolve.ts

🪛 GitHub Actions: CI
src/types.ts

[error] 124-124: error TS2552: Cannot find name 'LegacyNodeResolverOptions'. Did you mean 'NodeResolverOptions'?

src/utils/resolve.ts

[warning] 24-24: "import.meta" is not available in the configured target environment ("es2015") and will be empty

🔇 Additional comments (3)
src/utils/resolve.ts (2)

175-181: Consider extracting settings to a variable

The settings['import-x/resolve'] is accessed multiple times. Consider extracting it to a variable for better readability and maintainability.

-  } else if (
-    // backward compatibility for very old `import-x/resolve` options that is no longer supported
-    Object.prototype.hasOwnProperty.call(settings, 'import-x/resolve') &&
-    settings['import-x/resolve']
-  ) {
-    const resolveSettings = settings['import-x/resolve']
+  } else if (
+    // backward compatibility for very old `import-x/resolve` options that is no longer supported
+    Object.prototype.hasOwnProperty.call(settings, 'import-x/resolve') &&
+    settings['import-x/resolve']
+  ) {
+    const resolveSettings = settings['import-x/resolve']

This was already suggested in a previous review and implemented in a later commit.

🧰 Tools
🪛 GitHub Actions: Publish Any Commit

[error] Circular dependency: src/utils/resolve.ts -> src/utils/legacy-resolver-settings.ts -> src/utils/resolve.ts


182-188: Verify semantic equivalence between options

There may be a semantic mismatch between includeCoreModules (legacy) and builtinModules (new API).

-      builtinModules: resolveSettings.includeCoreModules !== false,
+      builtinModules: resolveSettings.includeCoreModules !== false,

This was flagged in a previous review. If includeCoreModules: false means "exclude core modules" in the legacy API, verify that builtinModules: false has the same meaning in the new API.

What's the difference between builtinModules and includeCoreModules in Node.js module resolution?
🧰 Tools
🪛 GitHub Actions: Publish Any Commit

[error] Circular dependency: src/utils/resolve.ts -> src/utils/legacy-resolver-settings.ts -> src/utils/resolve.ts

src/types.ts (1)

42-42:

✅ Verification successful

Verify moduleDirectory type compatibility

The type of moduleDirectory has been changed from what was likely an array to a single string. Make sure this is compatible with how it's used in the resolution logic.


🏁 Script executed:

#!/bin/bash
# Check for usages of moduleDirectory in the codebase
echo "Checking how moduleDirectory is used:"
rg "moduleDirectory" --include "*.ts" .

Length of output: 566


Action Required: Verify the moduleDirectory Type Usage

The moduleDirectory field in src/types.ts has been changed from an array to a string. The initial search using --include resulted in an error, so please re-run the query with the corrected flag to check how moduleDirectory is used throughout the code. For example, you can use the following script:

Once you verify that all usages of moduleDirectory expect a string (and not an array), you can confirm that the resolution logic remains correct. If any usage still treats it as an array, additional adjustments may be required.


🏁 Script executed:

#!/bin/bash
echo "Searching for usages of moduleDirectory in .ts files:"
rg "moduleDirectory" -g "*.ts" .

Length of output: 384


Confirmed: moduleDirectory Type Compatibility is Consistent

Based on the verification:

  • In src/types.ts, moduleDirectory is defined as an optional string.
  • In src/utils/resolve.ts, moduleDirectory is used by simply passing it to the modules field without any array-specific operations.
  • No evidence was found that any part of the resolution logic still expects moduleDirectory to be an array.

The change from an array to a string appears compatible with the current usage in the resolution logic.

Copy link

@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: 0

🧹 Nitpick comments (1)
src/types.ts (1)

45-48: Consider adding modules parameter support

Based on the previous review comments, there's a discussion about basedir and paths. It appears that modules is the replacement for paths in the new resolver.

Consider adding a comment about how users can migrate from paths to the modern equivalent in the new resolver, if applicable. This would help with the migration and backwards compatibility.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2a66b0a and 28189c5.

📒 Files selected for processing (2)
  • src/types.ts (2 hunks)
  • src/utils/resolve.ts (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/utils/resolve.ts
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: Lint and Test with Node.js 20 and ESLint 9 on windows-latest
  • GitHub Check: Lint and Test with Node.js 18 and ESLint 9 on windows-latest
  • GitHub Check: Lint and Test with Node.js 22 and ESLint 8 on windows-latest
  • GitHub Check: Lint and Test with Node.js 22 and ESLint 8.56 on windows-latest
  • GitHub Check: Lint and Test with Node.js 20 and ESLint 8 on windows-latest
🔇 Additional comments (4)
src/types.ts (4)

37-64: Interface name change aligns with migration to built-in resolver

The renaming from NodeResolverOptions to LegacyNodeResolverOptions clearly indicates this is for backward compatibility while the codebase migrates to the new built-in node resolver. The addition of properties marked as "Noop now" maintains the interface signature while properly documenting which options are no longer functional.


50-63: Effective use of the never type for no-op properties

Using the never type for deprecated properties is a good practice. It ensures TypeScript will raise an error if someone tries to use these properties, while still maintaining the interface shape for backward compatibility.


124-124: Property correctly updated to use new interface name

The property type has been correctly updated to reference the renamed interface, fixing the build failures noted in the previous review comments.


41-42:

❓ Verification inconclusive

Comment and type are inconsistent for moduleDirectory

The comment mentions "directory (or directories)" but the type has been changed from string[] to string, which only allows a single directory.

-  /** directory (or directories) in which to recursively look for modules. Default "node_modules" */
-  moduleDirectory?: string
+  /** directory in which to recursively look for modules. Default "node_modules" */
+  moduleDirectory?: string

Please verify if the built-in resolver supports multiple directories. If it does, consider using string | string[] to maintain backward compatibility.


🏁 Script executed:

#!/bin/bash
# Check if unrs-resolver supports multiple directories for moduleDirectory
rg -F "moduleDirectory" --context 10 --type ts node_modules/unrs-resolver

Length of output: 73


Action Required: Confirm Multi-Directory Support

The automated search did not reveal any indication that the built-in resolver supports multiple directories for moduleDirectory. At this point, the change updating the comment to suggest only a single directory (with the type remaining as string) appears appropriate. However, if the resolver actually supports an array (i.e., multiple directories), the type should be updated to string | string[] to maintain backward compatibility.

  • Location: src/types.ts at lines 41–42
  • Next Step: Please manually verify the built-in resolver’s source or documentation to confirm whether it accepts multiple directories for moduleDirectory. If it does, update the type accordingly; otherwise, the current single-string approach is correct.

Copy link

socket-security bot commented Mar 31, 2025

New, updated, and removed dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
npm/@jest/[email protected] None 0 28.3 kB simenb
npm/@jest/[email protected] None 0 6.07 kB simenb
npm/@jest/[email protected] None 0 32.7 kB simenb
npm/@nolyfill/[email protected] None 0 5.58 kB sukkaw
npm/@oxc-resolver/[email protected] None 0 770 kB boshen
npm/@oxc-resolver/[email protected] None 0 850 kB boshen
npm/@oxc-resolver/[email protected] None 0 910 kB boshen
npm/@oxc-resolver/[email protected] None 0 838 kB boshen
npm/@oxc-resolver/[email protected] None 0 811 kB boshen
npm/@oxc-resolver/[email protected] None 0 829 kB boshen
npm/@oxc-resolver/[email protected] None 0 942 kB boshen
npm/@oxc-resolver/[email protected] None 0 954 kB boshen
npm/@oxc-resolver/[email protected] environment 0 580 kB boshen
npm/@oxc-resolver/[email protected] None 0 643 kB boshen
npm/@oxc-resolver/[email protected] None 0 737 kB boshen
npm/@sinclair/[email protected] None 0 442 kB sinclair
npm/@swc/[email protected] None 0 0 B
npm/@swc/[email protected] None 0 37 MB kdy1
npm/@swc/[email protected] None 0 0 B
npm/@swc/[email protected] None 0 0 B
npm/@swc/[email protected] None 0 0 B
npm/@swc/[email protected] None 0 0 B
npm/@swc/[email protected] None 0 0 B
npm/@swc/[email protected] None 0 0 B
npm/@swc/[email protected] None 0 0 B
npm/@swc/[email protected] None 0 0 B
npm/@swc/[email protected] None 0 0 B
npm/@swc/[email protected] None 0 1.18 kB kdy1
npm/@swc/[email protected] None 0 234 kB kdy1
npm/@swc/[email protected] None 0 76.9 kB kdy1, kwonoj
npm/@total-typescript/[email protected] None 0 183 kB mpocock
npm/@types/[email protected] None 0 196 kB types
npm/@types/[email protected] None 0 3.57 kB types
npm/@types/[email protected] None 0 5.45 kB types
npm/@types/[email protected] None 0 7.92 kB types
npm/@types/[email protected] None 0 6.68 kB types
npm/@types/[email protected] None 0 78.8 kB types
npm/@types/[email protected] None 0 6.62 kB types
npm/@types/[email protected] None 0 5.3 kB types
npm/@types/[email protected] None 0 6.43 kB types
npm/@types/[email protected] None 0 8.65 kB types
npm/@types/[email protected] None 0 60.2 kB types
npm/@typescript-eslint/[email protected] None +1 53.6 kB
npm/@typescript-eslint/[email protected] None 0 14.5 kB jameshenry
npm/@typescript-eslint/[email protected] None 0 137 kB jameshenry
npm/@typescript-eslint/[email protected] None 0 96.2 kB jameshenry
npm/@unts/[email protected] environment, filesystem 0 421 kB jounqin
npm/@yarnpkg/[email protected] environment, eval, filesystem 0 280 kB arcanis
npm/[email protected] None 0 43.2 kB hirokiosame
npm/[email protected] None 0 46 kB simenb
npm/[email protected]9.23.0 None +1 2.9 MB eslintbot
npm/[email protected] None 0 146 kB simenb
npm/[email protected] filesystem 0 16.7 kB bmishkin
npm/[email protected] None 0 812 kB mattpauldavies
npm/[email protected] filesystem 0 3.01 kB sindresorhus
npm/[email protected] environment, filesystem 0 3.76 kB sindresorhus
npm/[email protected] None 0 78.5 kB simenb
npm/[email protected] None 0 3.79 kB simenb
npm/[email protected] None 0 28.4 kB simenb
npm/[email protected] None 0 20.6 kB simenb
npm/[email protected] environment +1 67.9 kB simenb
npm/[email protected] None 0 10.4 kB manidlou
npm/[email protected] environment, filesystem, shell 0 41.9 kB sindresorhus
npm/[email protected] environment, shell 0 20.2 kB boshen
npm/[email protected] None 0 60.7 kB simenb
npm/[email protected] environment 0 24 kB gnoff
npm/[email protected] unsafe 0 14.6 kB isaacs

🚮 Removed packages: npm/@eslint/[email protected], npm/@eslint/[email protected], npm/@eslint/[email protected], npm/@eslint/[email protected], npm/@eslint/[email protected], npm/@eslint/[email protected], npm/@eslint/[email protected], npm/@humanfs/[email protected], npm/@humanfs/[email protected], npm/@humanwhocodes/[email protected], npm/@humanwhocodes/[email protected], npm/@types/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected]

View full report↗︎

if (!enable) {
continue
}
} else if (
Copy link
Member

Choose a reason for hiding this comment

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

It seems not covering import-x/resolver#node, import-resolver#eslint-import-resolver-node and , import-x/resolver#<absolute-path-of-resolver-node>

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I want to leave those three in the major version bump. These could potentially be a breaking change (unlike import-x/resolve, which almost nobody uses, but we can run tests on it).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

IMHO, they can still use eslint-import-resolver-node explicitly, we should not stop it.

It is the import-x/resolve that is default to eslint-import-resolver-node and we need to replace that.

Copy link
Member

Choose a reason for hiding this comment

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

resolver-node is the default resolver and doesn't support exports, that's makes a lot of duplicate issues reported in upstream, as I mentioned above, if no specific features used by resolver-node options, we can safely use our new node resolver instead, otherwise we can just fallback to original resolver-node when unsupported options passed.

Then no breaking changes, and no regressions?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

resolver-node is the default resolver and doesn't support exports, that's makes a lot of duplicate issues reported in upstream, as I mentioned above, if no specific features used by resolver-node options, we can safely use our new node resolver instead, otherwise we can just fallback to original resolver-node when unsupported options passed.

Then no breaking changes, and no regressions?

The only default thing that happened here is in the import-x/resolve (without r); my PR is trying to remove it. There is nothing else that defaults to resolver-node.

Here is the thing, it is possible to have both node resolvers enabled:

// eslint.config.js
export default [
  { files, settings: { 'import-x/resolve': legacy } },
  { files, settings: { 'import-x/resolve': lessLegacy } }
];

Then it just becomes "why my exports are not working? I have already updated to the latest version! You are lying in the CHANGELOG!". Or "exports only works times to times!"

Let's just not overcomplicate things. If they explicitly declare node in the import-x/resolver (soon to become import-x/resolver-legacy), then we use resolver-node. Only if nothing is explicitly defined then we use our built-in node resolver by default.

Copy link
Member

@JounQin JounQin Apr 2, 2025

Choose a reason for hiding this comment

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

Removing resolver-node from dep already breaks the related users.

We can warn and document if unsupported options passed, it'll fallback to original resolver-node.

I think resolver-node should be an optional peer.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hmmmm. You are right. Let's move this to the breaking change then, and no legacy options will be supported. Closing now.

Copy link
Member

Choose a reason for hiding this comment

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

I still want to support it with my proposal, so I'll continue your work to finish it.

@JounQin
Copy link
Member

JounQin commented Mar 31, 2025

@SukkaW Do you want me to wait #273 for this PR?

@SukkaW
Copy link
Collaborator Author

SukkaW commented Apr 1, 2025

@SukkaW Do you want me to wait #273 for this PR?

Let's do this in a separate release then. Feel free to drop a release now!

Co-authored-by: JounQin <[email protected]>
Copy link

@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: 0

🧹 Nitpick comments (3)
src/types.ts (3)

47-48: Fix incomplete comment for paths property

The comment for the paths property is incomplete and doesn't fully explain its previous purpose.

-  /** Noop now. Previously for require.paths array to */
+  /** Noop now. Previously for require.paths array to use if nothing is found on the normal node_modules recursive walk */

39-44: Consider adding default values in comments

For properties like includeCoreModules, moduleDirectory, and preserveSymlinks, it would be helpful to include their default values in the comments to provide better guidance for users.

-  /** set to `false` to exclude node core modules (e.g.` fs`) from the search */
+  /** set to `false` to exclude node core modules (e.g.` fs`) from the search. Default: true */
-  /** directory (or directories) in which to recursively look for modules. Default "node_modules" */
+  /** directory in which to recursively look for modules. Default: "node_modules" */
-  /** if true, doesn't resolve basedir to real path before resolving. This is the way Node resolves dependencies when executed with the --preserve-symlinks flag. Default to true */
+  /** if true, doesn't resolve basedir to real path before resolving. This is the way Node resolves dependencies when executed with the --preserve-symlinks flag. Default: true */

45-63: Ensure consistency in comment style

There's a slight inconsistency in the comment style for the noop properties. Some use "Noop now, Previously..." while others use "Noop now. Previously..." (with a period).

Consider standardizing to one style for consistency, preferably "Noop now. Previously..." (with a period) as it's used more frequently in the code.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2b0fce1 and d21b8d8.

📒 Files selected for processing (2)
  • src/types.ts (2 hunks)
  • src/utils/resolve.ts (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/utils/resolve.ts
🔇 Additional comments (2)
src/types.ts (2)

37-64: LGTM: Interface structure is clear with appropriate documentation

The LegacyNodeResolverOptions interface is well-organized with clear documentation of which options are now no-ops versus those that remain functional. This approach properly maintains backward compatibility while moving to the new built-in node resolver.


124-124: Properly updated type reference in ImportSettings

This properly updates the type reference to use the new LegacyNodeResolverOptions interface.

@SukkaW SukkaW requested a review from JounQin April 1, 2025 13:33
builtinModules: resolveSettings.includeCoreModules !== false,
modules: [
resolveSettings.moduleDirectory,
...(resolveSettings.paths ?? []),
Copy link
Member

Choose a reason for hiding this comment

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

paths should only be applied when moduleDirectory fails to resolve (found: false).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Well. Probably just implements this in unrs-resolver TBH.

Copy link
Member

@JounQin JounQin Apr 2, 2025

Choose a reason for hiding this comment

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

That could be confusing between modules vs paths, and I think that's why this is not implemented in enhanced-resolve. paths is also discouraged by resolve itself:

opts.paths - require.paths array to use if nothing is found on the normal node_modules recursive walk (probably don't use this)

@SukkaW SukkaW closed this Apr 2, 2025
@JounQin JounQin reopened this Apr 2, 2025
Copy link

sonarqubecloud bot commented Apr 2, 2025

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.

2 participants