This repository was 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
Merged
fix(vite): respect ctx.nuxt.options.modulesDir for resolving externals with vite-node#7612
ctx.nuxt.options.modulesDir for resolving externals with vite-node#7612Conversation
✅ Deploy Preview for nuxt3-docs canceled.
|
pi0
commented
Sep 16, 2022
| const result = await isExternal(id) | ||
| if (result?.external) { | ||
| return resolveModule(result.id, { url: ctx.nuxt.options.rootDir }) | ||
| return resolveModule(result.id, { url: ctx.nuxt.options.modulesDir }) |
Member
Author
Member
There was a problem hiding this comment.
The id passed here should already be resolved by Vite. So yes I think we could directly do this.
Member
Author
There was a problem hiding this comment.
Thanks for checking. FYI, it is not always resolved. You can reproduce it only with an external repository by putting a debugger. vue for instance is directly passed to shouldExternalize.
Member
Author
|
Merging as hotfix. |
ctx.nuxt.options.modulesDir for resolving externalsctx.nuxt.options.modulesDir for resolving externals with vite-node
This was referenced Jan 19, 2023
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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_modulesand finally different resolvedvueversion. (Correct way is settingrootDir + '/_node_modules'orrootDir + /index.mjs)This PR resolves issue by respecting
modulesDirfor resolvingvueand other dependencies. In the future we might come of with better implementation to actually reuse same vite resolution. I didn't usereturn idon 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 tonullas it is unable to determine external status.📝 Checklist