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

Module field breaking CommonJS resolution #7578

Open
7 tasks done
SteveALee opened this issue Apr 2, 2022 · 2 comments · Fixed by #7582
Open
7 tasks done

Module field breaking CommonJS resolution #7578

SteveALee opened this issue Apr 2, 2022 · 2 comments · Fixed by #7582
Labels
p3-minor-bug An edge case that only affects very specific usage (priority)

Comments

@SteveALee
Copy link
Contributor

Describe the bug

A function in a nested require is not correctly processed.

sodatea said on discord:

A small bug in Vite's resolution algorithm. There's a module field in callbag-from-event, while callbag-for-each only has main. https://unpkg.com/browse/callbag-from-event@1.3.0/package.json#L10 module has higher precedence in Vite than main. https://github.com/vitejs/vite/blob/a74bd7ba9947be193bccf636b8918bd1f59e89ae/packages/vite/src/node/plugins/resolve.ts#L778-L786

The fix is similar to #7438 that module or jsnext fields should be skipped when it's initiated by a require call.

Reproduction

See https://stackblitz.com/edit/vitejs-vite-wthjcb?file=main.js

System Info

N/A

Used Package Manager

npm

Logs

No response

Validations

@patak-dev
Copy link
Member

@SteveALee re-opening as we needed to revert #7582, see #7737 for more context. I discussed with @sodatea and he has an idea for another fix, but it may require a new option so it will probably take a bit more time to get this one fixed.

@patak-dev patak-dev added bug p3-minor-bug An edge case that only affects very specific usage (priority) and removed pending triage labels Apr 14, 2022
@SteveALee
Copy link
Contributor Author

@patak-dev oops, don't you just hate it when that happens!? Thanks for letting me know!

@patak-dev patak-dev removed the bug label Feb 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p3-minor-bug An edge case that only affects very specific usage (priority)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants