use fs.realpath to resolve module locations #2946
Closed
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.
↪️ Pull Request
This updates the way node modules are resolved by the Parcel resolver such that the "real path" is used. This way it matches the node resolution algorithm and makes Parcel compatible with other tools in the node ecosystem that rely on this behavior (like pnpm).
See issue #1125 which this PR would address.
💻 Examples
A pnpm workspace has this issue with transitive dependencies. For example, if a module in the workspace uses React, then Parcel will not find React's transitive dependencies (usually failing to find
object-assign
).pnpm sets up a folder structure like this:
Because Parcel ignores the real path, it tries to find
object-assign
like this:/monorepo/web-ui/node_modules/react/node_modules
/monorepo/web-ui/node_modules/
/monorepo/node_modules
<-- not found here because it's in subfolder .registry.npmjs.org🚨 Test instructions
TODO: I may be able to contribute some tests, looking for guidance here
✔️ PR Todo