question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:

  1. Clone the repository.
  2. Go into the library folder and run yarn + yarn build. This build the library, and also installs preact into node_modules as it’s listed as dev dependency.
  3. Exit library and enter app.
  4. Install dependencies with yarn, this installs the second installation of preact as it’s listed as a dependency.
  5. Build and serve with yarn serve.
  6. Go to http://localhost:1234/report.html to view the bundle report. Notice preact is 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:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:5

github_iconTop GitHub Comments

2reactions
tripolskypetrcommented, Nov 18, 2021

Hello there! Still waiting for React components library bundling support on Parcel 2…

image

0reactions
michoxcommented, Jul 8, 2022

This issue is still occurring, can we reopen this issue, please?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Dependency resolution - Parcel
A dependency specifier is a string that describes the location of a dependency relative to the file that imports it. For example, in...
Read more >
How do I fix the npm UNMET PEER DEPENDENCY warning?
if I do an npm install, then get a list of a bunch of unmet dependencies that I have to manually add to...
Read more >
How to handle peer dependencies when developing modules
So if you're developing react-foo which has a peer dependency on react , you'll just have to go into your application, run yarn...
Read more >
pnpm issues with peer dependencies found - You.com | The search ...
The declared peerDependency is installed but installed version doesn't match declared version, but luckily the installed version doesn't have break changes ...
Read more >
npmrc | pnpm中文文档
The directory in which dependencies will be installed (instead of node_modules ). ... If you have some dependencies with very long paths, you...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found