Skip to content

Replacing the built-in default import resolver that supports exports and imports from package.json #208

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

Closed
SukkaW opened this issue Dec 18, 2024 · 5 comments · Fixed by #209

Comments

@SukkaW
Copy link
Collaborator

SukkaW commented Dec 18, 2024

eslint-plugin-import-x has eslint-import-resolver-node as a dependency. When no resolver is specified in the eslint config, the eslint-import-resolver-node will be used. However, eslint-import-resolver-node doesn't support exports and imports from package.json and @ljharb simply refuses doesn't have time to implement this feature and even locks the feature request issue, see import-js/eslint-plugin-import#1810.

So our plan is to abandon the eslint-import-resolver-node. We will be building a new eslint import resolver upon @dual-bundle/import-meta-resolve enhanced-resolve. We will ship it with eslint-plugin-import-x and it will be an interface v3-only resolver.

In the next major version of eslint-plugin-import-x, we will remove eslint-import-resolver-node in favor of our own default resolver.

@SukkaW SukkaW pinned this issue Dec 18, 2024
@SukkaW
Copy link
Collaborator Author

SukkaW commented Dec 18, 2024

Note that the default resolver will try to match the Node.js resolving behavior, so no jsconfig.json or tsconfig.json support. Anyone interested in those should checkout eslint-import-resolver-typescript, eslint-import-resolver-oxc, or eslint-import-resolver-next (which is also based on oxc).

@silverwind
Copy link
Contributor

Why not use import.meta.resolve for the node resolver? Is it because it's synchronous only?

@ljharb
Copy link
Contributor

ljharb commented Dec 18, 2024

To be clear, i certainly don’t refuse to implement the feature; it’s that to do it properly takes more time than I’ve had yet (and can’t be done with only require.resolve/import.meta.resolve, because people frequently need to lint for node versions different from the one they’re running)

@SukkaW
Copy link
Collaborator Author

SukkaW commented Dec 19, 2024

Why not use import.meta.resolve for the node resolver? Is it because it's synchronous only?

Yes. The resolving happens inside the ESLint plugin, and the ESLint plugin needs to be synchronous. Besides import.meta.resolve only exists in ESM while both eslint-plugin-import-x and eslint-plugin-import have many users working with CJS.

@JounQin
Copy link
Member

JounQin commented May 31, 2025

@un-ts un-ts locked and limited conversation to collaborators May 31, 2025
@un-ts un-ts unlocked this conversation May 31, 2025
@JounQin JounQin unpinned this issue May 31, 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 a pull request may close this issue.

4 participants