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
Packages using self-referencing imports will fail to resolve ("moduleResolution": "node16" and package.json "exports") #9731
Comments
I am facing same issue with a third party package but issue only occurs on build and not on dev. Error on running
|
I have a similar monorepo setup where a package references itself to avoid
|
interestingly enough it works fine when the package with the same content is put into a real node module, and loaded then |
There in seems to lie the clue. if you symlink your packages into the root node_modules, it starts working! |
Also running into this. Not sure why it happens only in some configurations though, in other projects it works fine to locally reference packages with self imports. |
It happens only in some configurations because package manager sloppiness often hides the bug, by making a package's name resolvable in more than one way. You end up "falling back" to a higher-level node_modules folder that just happens to have a symlink to the package. But that's not what node itself does. Vite's resolver plugin doesn't implement this feature correctly. The logical place to do it would be about here:
since that has already located the relevant package.json and is doing the |
Is this being worked on or...? |
Another reproduction from #13409 (comment) |
Wanted to have this in Vitest but the related issues are closed, so I’m referencing them here for anyone interested: |
Describe the bug
The given repository will fail in both
dev
&build
due to a package using Self-referencing import that is defined to work for packages that specifyexports
inpackage.json
under the newer node module resolution rules. AKA"moduleResolution": "node16"
intsconfig.json
.Reproduction
https://github.com/segevfiner/vite-self-reference
System Info
Validations
The text was updated successfully, but these errors were encountered: