Added support for externals through peer dependencies #3674
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.
Allows parcel to not bundle the peerDependencies of a project and leave them as external requires. This makes it convenient to use parcel for bundling libraries or packages linked locally.
#144
#3305
It works by skipping the package in the node resolve algorithm if it was specified as a peer dependency (as if it was not there in the first place). The resolve algorithm can thus find the package higher up the tree where it was not specified as a peer dependency. In case it did not resolve (as all instances of the package in the tree are specified as a peer dependency), it will be ignored as a dependency and leave the require statement in place.
I find this useful for consuming local packages that have for example a "react" peer dependency. React should not be bundled multiple times as this makes React complain. Also useful to leave "@babel/runtime" requires in place for packages/libraries that want to depend on the babel runtime.