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
Duplicate id for the same dependency #1181
Comments
I've created an example to illustrate the bug. You can find the code in this repo: https://github.com/tleunen/browserify-1181 In this file (app.min.js), you can find React twice with 2 separate ids (at the end of the file). And the way I can reproduce it is by including a file from a top directory (like in this file). |
This is deduping behavior caused by an upstream dependency requiring the same version of react. And my guess is that react is built around the assumption that it is the only instance in your app. If you |
@substack You're correct. React borks like crazy if there are multiple versions trying to co-exist. |
I'm experiencing a similar issue with a module attempting to inject itself into jquery. Removing the duplicate jquery from the module's node_modules/ directory solved the problem. That said, it seems like browserify recognizes that the packages are duplicated. Why couldn't it (in the above instance) simply give 158 to the second package require()ing React instead of creating 314 to de-duplicate it? |
@ericclemmons @substack — along the same lines, using React, I have two libraries that i'm working on locally and using
On the server-side, everything is fine since there's only one instance of React on the process. But I haven't figured out how to work it out in the bundle yet. I would be grateful for any ideas or suggestions. |
@pgoldrbx Similar issue for me. To be honest, I couldn't find a fix, and ultimately started pruning all As best I can assume, the same |
I think our issue is actually described here already: |
I have found that browserify-resolutions solves the problem. I had the same problem with jquery plugins, I had one instance for each jquery called by each plugin. browserify-resolutions fixed it. |
I think this is now fixed since #1063 is now closed (changes have been merged) |
@chrisirhc Not really. If the dependency is depended upon twice, it will have 2 ids. If |
You can resolve this by linking For example, I assuming
This tells browserify (and node) that you want the exact same |
@chrisirhc It makes no sense that I should have to manually enter the |
I'm playing with Browserify and React today and in my bundle I'm noticing that React is loaded with 2 different dependency number. One is 158 and the other is 314.
In the bundle file, I can see this for 314
158 is basically just a shortcut for
module.exports = require('./lib/React');
which is 187.My code is broken because of that, because it loads the dependency twice.
The text was updated successfully, but these errors were encountered: