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

import/no-unresolved doesnt respect package exports #2389

Closed
thepassle opened this issue Feb 24, 2022 · 8 comments
Closed

import/no-unresolved doesnt respect package exports #2389

thepassle opened this issue Feb 24, 2022 · 8 comments

Comments

@thepassle
Copy link

If I import something from package foo, that has in it's package.json the following exports map:

"exports": {
  "./bar.js": "./src/bar.js"
}

The following import will cause an import/no-unresolved error, while being completely valid:

import 'foo/bar.js';
@ljharb
Copy link
Member

ljharb commented Feb 24, 2022

Duplicate of #1810.

@ljharb ljharb closed this as completed Feb 24, 2022
@ljharb
Copy link
Member

ljharb commented Feb 24, 2022

I'd suggest making that package have an actual ./bar.js file, so that pre-exports nodes (and tooling) can locate the file also.

@thepassle
Copy link
Author

A better structural fix would be for tooling to catch up with package exports instead

@ljharb
Copy link
Member

ljharb commented Feb 24, 2022

Both fixes are needed; packages should remain backwards-compatible, instead of being hostile to those users.

Certainly this package, and the ecosystem's tooling, will eventually catch up as well.

@thepassle
Copy link
Author

packages should remain backwards-compatible, instead of being hostile to those users

The foo package I mentioned doesnt have this requirement

@ljharb
Copy link
Member

ljharb commented Feb 24, 2022

I gathered that - I'm saying that all packages should have that requirement.

@thepassle
Copy link
Author

I disagree with that, but I guess its besides the point. You mentioned that "eventually" this plugin will support package exports, the issue you linked has been open for 2 years, is there already work started to support package exports? If not, would you be willing to take a PR? I might be able to spend some time and take a stab at it

@ljharb
Copy link
Member

ljharb commented Feb 24, 2022

The work needs to be done in the resolve package; it has begun and is moving slowly.

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

No branches or pull requests

2 participants