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

(fix): eslint import/no-unresolved issue #31

Closed
wants to merge 1 commit into from

Conversation

mzonski
Copy link

@mzonski mzonski commented Aug 21, 2024

Because of the missing 'main' key the eslint-plugin-import:resolver:node cannot resolve the package as a directory, thus throwing import/unresolved error/warning.

Here's the link to the place in code that is failing: https://github.com/browserify/resolve/blob/fd788d94d037e32d4f4be948e2f7e15f6981f004/lib/sync.js#L180

If the main is not set, it defaults to index.js in the package's root folder, you're exporting index.js and declaration in the dist directory thus it's producing an error in the code pointed upper.

Because of the missing 'main' key the eslint-plugin-import:resolver:node wasn't able to resolve the package as a directory, thus throwing import/unresolved error/warning.

Here's the link to the code which is failing: https://github.com/browserify/resolve/blob/fd788d94d037e32d4f4be948e2f7e15f6981f004/lib/sync.js#L180

If main is not set, it defaults to index.js in the package's root folder, you're exporting index.js and declaration in the dist directory thus it's producing an error in the code pointed upper.
@Septh
Copy link
Owner

Septh commented Aug 25, 2024

In ESM packages like this one, the main field is superseded by the exports field. See the Node's documentation about exports.

I'm afraid the browserify/resolve package is outdated. They should support exports. I suggest you file an issue on their repository because this is not something I intend to support for them.

Leaving this PR open for now, but will probably close it with won't fix soon.

@mzonski
Copy link
Author

mzonski commented Aug 27, 2024

I can't say you are wrong with these assumptions, but I cannot tell that mine are bad. By merging this Pull request you will greatly improve backward compatibility with the various tools used across Node ecosystem.

It's fine for me if you decide not to merge these changes, but let me tell you - this is the only package in my rollup configuration throwing the unresolved error due to lack of the "main" definition - check it here

In this pull request they're trying to add support for the default node import behavior. I believe I will find a wife sooner than this PR is merged or they do proper code changes, and then the ESLint plugin resolver needs to be updated with these changes. It's a long chain of events.

@Septh Septh closed this Oct 11, 2024
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