Skip to content
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

react-bootstrap, lodash, and factor-bundle not playing well together #79

Closed
micah-bloomerang opened this issue Jan 12, 2016 · 8 comments

Comments

@micah-bloomerang
Copy link

I've been working on this problem for a couple of days, and I think I finally have it narrowed down. If I'm using factor-bundle where one file contains a reference to lodash and the other file contains a reference to react-bootstrap, I get the following error:

TypeError: Cannot read property '0' of undefined

Here is what is needed to reproduce:

npm install factor-bundle lodash react-bootstrap

index.html

<html>
<body>
<script type="text/javascript" src="bundle/common.js"></script>
<script type="text/javascript" src="bundle/index.js"></script>
</body>
</html>

main/index.js

require('../node_modules/react-bootstrap');

main/bad.js

require('../node_modules/lodash/object/keys');

Build with:

browserify main/index.js main/bad.js -p [ factor-bundle -o bundle/index.js -o bundle/bad.js ] -o bundle/common.js
@djforth
Copy link

djforth commented Jan 27, 2016

+1 I'm getting a similar issue

@micah-bloomerang
Copy link
Author

@djforth any differences in your issue? Maybe we can find a common thread.

@mrkrstphr
Copy link

This seems related to #51

@djforth
Copy link

djforth commented Feb 12, 2016

Hi Sorry for the late reply, I think my issue was 2 fold. Firstly my common bundle seemed to loading after my other bundles because of async and secondly it was a dependancy mismatch. Once I had sorted it so that my internal modules where all the same + using peerDependancy over dependancy in the modules the issue seemed to disappear. Hope that helps.

@magalhini
Copy link

I'm having the exact same issue and I am quite, quite desperate now. It took me three days to narrow it down to factor-bundle... apparently, if I require more than one module twice with Browserify, I'm also getting the following error:

TypeError: Cannot read property '0' of undefined

If I duplicate a module and give it a different name, everything works as expected.
This was working fine until I recently updated React and Babel to their latest versions (React 0.13 and Babel 5.x were working fine). Any leads?

@magalhini
Copy link

@djforth Could you please give me some more details about your dependency mismatch? How did you narrow them down to the root cause?

@tellnes
Copy link

tellnes commented Mar 1, 2016

This might be related to the problem in browser-pack that browserify entries are required before the require method is exposed to the global scope. When you are using multiple bundles browserify depends on a global require variable.

I've got an open pull request fixing that (browserify/browser-pack#73), but it has no response yet.

@micah-bloomerang
Copy link
Author

I was only seeing this issue in lodash v3 (was using v3.10.1), but after upgrading lodash to v4 (v4.6.1), I no longer see the issue. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants