-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Add exports
field to subpackages to align module resolution with the root level package.json
#3564
Comments
That is intentional, we don't use type module so main is cjs |
|
In my codebase I delete node_modules preact/hooks package.json to fix this. |
I am aware of the workaround 😄 I'm interested to get feedback from maintainers if this behaviour is desirable. |
@developit is your best bet for that, was before me joining |
FYI: We added those These days with the The criteria for removing them here are:
Either way I'd love to see them be removed too. |
@marvinhagemeister |
As I said, Vitest doesn't enforce it by default because of the reasons you described, but users can configure that. I'm just trying to find a solution here for the end user. Maybe we can at least have both |
That doesn't sound correct. Users aren't configuring whether or not Node's extension semantics should be enforced, but what entry conditions are able to be used. If consuming a valid & spec compliant While we do probably want to revise the setup here, that would only (maybe) fix the issue for Preact. Any usage of |
Importing with
Your
That is correct. Usually this packages will also have an In this specific issue problem comes from Svelte that adds |
Sorry, I don't follow. Are you stating that Vitest falls back to
Node has no way of consuming The entry predates Node's semantics by quite a bit, hence why Node moved to
Better solution long-term would probably be to adhere to the |
No. I am saying that
This is why I am asking to also add
What do you mean? We are trying to focus on performans, so we don't run external libraries themselves, but delegate it to Node. We also don't have a resolution algorithms, it is inside Vite, so we don't know if it's a I also think "better solution long-term" is for libraries to have correct bundlers fields and |
Gotcha!
I mean that if you're going to allow users to consume from
Sorry, take my comments re:Vitest with a big grain of salt; I don't know where/how it connects up to Vite. I use neither tool. Whichever is resolving
I meant "better solution long-term" in reference to the entire Node ecosystem. |
Vite team does this since the start, we are just helping with that. I thinks it's better that way, because it also affects SSR.
If it's correct then why So I am just asking, can you also add
As I said before this is rarely an issue, because we don't process |
To conclude, your If you have the |
Well, fair enough. Good luck! Honestly I do hope that continues to go well.
You may think that's a rhetorical question, but the reality is that they're both correct as they do different things and need to abide by different specs. It's not "inconsistent" as they're two different things. They aren't supposed to match necessarily* (
I imagine this was just a case of every other tool using the root root
I'm not sure what I've said that makes you think I'm starting a conspiracy theory(?) here? Apologies, that's certainly not my intention.
Sure, and that's fair enough of course. Just warning that an incorrect handling of |
I don't mean inconsistency in that way. I know perfectly well why you have both |
module
entry for preact/hooks
?exports
field to subpackages to align module resolution with the root level package.json
Sorry, I thought you were referring to the previous sentence with that comment:
|
Describe the bug
While working on vitest-dev/vitest#737 I found that
preact/hooks
module
entry points to cjs package instead ofhooks.mjs
. Is this intentional?If I change it to
.mjs
everything works fine. Usually Vitest doesn't resolve what is stored inmain
field, but it is configurable withresolve.mainFields
Vite option (this is what Svelte is doing).So, I guess Vite prioritizes closest
package.json
resolvings instead of root level packageexports
.Might be related: preactjs/preset-vite#52
To Reproduce
Reproduction: https://github.com/molily/vitest-test/tree/preact-and-svelte
pnpm run vitest
Expected behavior
No error
The text was updated successfully, but these errors were encountered: