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
refactor(kit,nuxi): resolve module paths using node algorithm #19537
Merged
Conversation
This file contains 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
Β Open in CodeSandbox Web Editor | VS Code | VS Code Insiders |
This is a really lovely initiative! Only I think we should use mlly.resolvePath that wraps same package internally for less deps, more consistency and path normalizations. |
danielroe
changed the title
refactor(kit,nuxi): use
refactor(kit,nuxi): resolve module paths using node resolver algorithm
Mar 10, 2023
import-meta-resolve
to resolve module paths
pi0
approved these changes
Mar 10, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good must have to me π
danielroe
changed the title
refactor(kit,nuxi): resolve module paths using node resolver algorithm
refactor(kit,nuxi): resolve module paths using node algorithm
Mar 10, 2023
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
#18431 (comment)
β Type of change
π Description
The linked issue is caused by us trying to resolve an ESM module's path by CJS utilities, and then import it with native ESM.
This refactors our internal CJS utils in kit + nuxi to use
resolvePath
frommlly
which usesimport-meta-resolve
under the hood (a polyfill for the Node built-in). To decrease the change surface, I've restricted changes to places where we have a single search path (e.g. rootDir or cwd) and have kept the existing behaviour where we have multiple paths (e.g. wherenuxt.options.modulesDir
is used).I would be up for refactoring the remaining usage of CJS utils as well, but am also happy to defer that to a subsequent PR.
As part of this, the behaviour of
tryResolveModule
(exposed by kit) has changed (it is now async, it now returns a file URL, and it takes a single string as a second argument rather than an object). However, I think this is safe as it was a deprecated internal module and not used outside of nuxt itself.I've also decreased the number of internal utilities we are exposing from the CJS part of kit as a number of them are not being used elsewhere in the repo.
π Checklist