import-js / eslint-plugin-import

ESLint plugin with rules that help validate proper imports.
MIT License
5.56k stars 1.57k forks source link

`no-unresolved` is not aware of `exports` definition in `package.json` #1810

Open ignatiusreza opened 4 years ago

ignatiusreza commented 4 years ago

From this announcement

Package entry points and the package.json “exports” field

There are now two fields that can define entry points for a package: “main” and“exports”. The “main” field is supported in all versions of Node.js, but its capabilities are limited: it only defines the main entry point of the package. A new package.json field “exports” can also define the main entry point, along with subpaths. It also provides encapsulation, where only the paths explicitly defined in “exports” are available for importing. “exports” applies to both CommonJS and ES module packages, whether used via require or import.

Might need to be fix in resolve package..

conartist6 commented 11 months ago

Could you clarify: why do really old node versions need to be able to resolve exports though? Or is there some other use case I'm missing?

ljharb commented 11 months ago

The use cases for resolve are far more plentiful than for eslint. resolve needs to resolve, in any node version, a path as if it would be resolved in any other node version. A pre-exports node may want to emulate “exports”. A post-exports node may want to emulate pre-exports. A modern node may simply want to know what a pre-exports node user would see.

piranna commented 11 months ago

I think the sane solution here is to don't worry at all about any unmaintained Node.js version, it's said, don't provide support for anything older than Node.js v18.

conartist6 commented 11 months ago

I really don't buy that the only way to have good compatibility is if there is a single implementation of the algorithm. Tons of projects are already using enhanced-resolve anyway, and putting a new implementation out in ESLint will be an amazing way to safely get feedback on whether there is behavioral parity.

ljharb commented 11 months ago

@piranna ”sane” isn’t an appropriate word to be using in this context; and almost all of my packages support down to node 0.4, and will continue to do so for the foreseeable future. Platform support has no correlation to what a package should support.

ljharb commented 11 months ago

@conartist6 thats fine, your agreement isn’t required.

conartist6 commented 11 months ago

I think this is great because now we're unblocked. It's clear from this conversation that my beliefs about the problem are different enough from yours that I should build a new package, and that it will be clearly differentiated in the marketplace.

conartist6 commented 11 months ago

Everyone who just wants to use the new stuff can stop bugging you, which is a win for you as well.

ljharb commented 11 months ago

Go for it. As you said tho, there’s already packages that do this, so i don’t think there’s much value in yet another one; the value is in resolve itself doing it.

conartist6 commented 11 months ago

I would agree that all that was off-topic if this were a conversation on the resolve package, but as this is eslint-plugin-import parts of that conversation seem quite relevant.

To recap the now-hidden conversation:

I believe that in sum this means that eslint-plugin-import should seek out a resolve implementation which is better aligned with its needs and the needs of its users.

ljharb commented 11 months ago

It won’t; using resolve - the most common implementation - is what is most aligned with it and its users needs.

Again, your agreement isn’t required, and to be clear, is also irrelevant.

conartist6 commented 11 months ago

I would appreciate if you would allow my condensed argument to stand as a matter of public record. Please?

ljharb commented 11 months ago

Your summary would be fine; your conclusion would only distract.

conartist6 commented 11 months ago

The comment may be deleted now, but I'm still calling it out. That was rude and inappropriate. We can compete with and disagree with other people and still respect them.

ljharb commented 11 months ago

@conartist6 no comments were deleted afaict, so I’m not sure what you’re referring to.

conartist6 commented 11 months ago

Not deleted by you then, but it was emailed to anyone who subscribes to this thread.

ljharb commented 11 months ago

ah, yes, i found it in my email :-) some people have nothing better to do, i guess.

conartist6 commented 11 months ago

I feel that you have abused your position as a moderator to protect your image in the face of reasoned dissent, so I can't say I'm that thrilled with you at the moment.

conartist6 commented 11 months ago

Is there an ombudsman or another moderator who could assist in untangling this?

conartist6 commented 11 months ago

I'm not wedded to any particular outcome, but it's unacceptable to me that all discussion on the topic should be summarily silenced.

ljharb commented 11 months ago

It’s just me, and what’s acceptable is only up to collaborators. I’m going to lock the thread for a bit.

Additionally, hiding comments isn’t silencing anything - that’d be called “deleting comments”. I’m just making them hidden by default so they don’t distract new readers of the issue.