This repository has been archived by the owner on Apr 6, 2023. It is now read-only.
fix(vite): respect ctx.nuxt.options.modulesDir
for resolving externals with vite-node
#7612
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
π Linked issue
resolves nuxt/nuxt#14952, nuxt/nuxt#14907, nuxt/nuxt#14802, nuxt/nuxt#14928
β Type of change
π Description
We are overriding
shouldExternalize
(PR: #6153) of vite-node, and use mlly resolver to directly resolve paths. Issue with nuxt/nuxt#14952 happens because directly setting URL to the directory ofrootDir
, causes resolving from parentnode_modules
and finally different resolvedvue
version. (Correct way is settingrootDir + '/_node_modules'
orrootDir + /index.mjs
)This PR resolves issue by respecting
modulesDir
for resolvingvue
and other dependencies. In the future we might come of with better implementation to actually reuse same vite resolution. I didn't usereturn id
on external branch (while it works!) until getting confirmation from @antfu. Vite-node's default external handler however does this. srcAlso worth to mention that
isExternal('vue')
resolves tonull
as it is unable to determine external status.π Checklist