Parcel ignoring PeerDependency if dependency has been installed in a library
See original GitHub issue🐛 bug report
When using experimental scope hoisting the PeerDependency list is ignored for libraries when the dependency is also in node_modules. Any dependencies are included twice in the final bundle.
🎛 Configuration (.babelrc, package.json, cli command)
https://git.dany.dev/dsluijk/parcelpeers
🤔 Expected Behavior
There should be only one entity of a library in the final bundle output.
😯 Current Behavior
Two instances of the same library are included in the bundle, inflating the bundle unnecessary.
💁 Possible Solution
Check if a library is in peerdependencies before adding it into the bundle. As it’s a peer dependency it’s fair to assume another installation will be bundled.
🔦 Context
The library has the dependency both listed as dev as well as peer dependency. This is needed because we need it as a dev dependency for the build step, and as a peer dependency for actual usage of the library.
💻 Code Sample
I’ve created an example project here: https://git.dany.dev/dsluijk/parcelpeers
To reproduce:
- Clone the repository.
- Go into the
libraryfolder and runyarn+yarn build. This build the library, and also installspreactintonode_modulesas it’s listed as dev dependency. - Exit
libraryand enterapp. - Install dependencies with
yarn, this installs the second installation ofpreactas it’s listed as a dependency. - Build and serve with
yarn serve. - Go to http://localhost:1234/report.html to view the bundle report. Notice
preactis included twice here.
🌍 Your Environment
| Software | Version(s) |
|---|---|
| Parcel | 1.12.4 |
| Node | 15.1.0 |
| npm/Yarn | Yarn 1.12.4 |
| Operating System | Arch Linux x86_64, 5.9.6-arch1-1 |
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:5

Top Related StackOverflow Question
Hello there! Still waiting for React components library bundling support on Parcel 2…
This issue is still occurring, can we reopen this issue, please?