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

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

Closed
SukkaW opened this issue Dec 18, 2024 · 4 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#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

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

@ljharb
Copy link

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.

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.

3 participants