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

Does not work with react-bootstrap #59

Open
EvanCarroll opened this issue Feb 11, 2015 · 3 comments
Open

Does not work with react-bootstrap #59

EvanCarroll opened this issue Feb 11, 2015 · 3 comments

Comments

@EvanCarroll
Copy link

Simple test with react-bootstrap

https://github.com/EvanCarroll/debowerify-fail

$ sh FAIL.sh 
Error: Cannot find module './joinClasses' from '/tmp/fail/public/bower_components/react-bootstrap'
    at /usr/local/lib/node_modules/browserify/node_modules/resolve/lib/async.js:42:25
    at load (/usr/local/lib/node_modules/browserify/node_modules/resolve/lib/async.js:60:43)
    at /usr/local/lib/node_modules/browserify/node_modules/resolve/lib/async.js:66:22
    at /usr/local/lib/node_modules/browserify/node_modules/resolve/lib/async.js:21:47
    at Object.oncomplete (fs.js:93:15)

react-bootstrap/index.js has a series of requires

Accordion: require('./Accordion')

While the file, ./Acordion.js has itself a series of requires.

var joinClasses = require('./utils/joinClasses');

These don't seem to be resolvable with react-bootstrap.

@bobthecow
Copy link
Collaborator

That's because the bower version of react-bootstrap isn't CommonJS compatible, it's made for using in a browser.

Per their bower.json, the main file is react-bootstrap.js, a pre-built AMD/browser global file that's not meant to be used inside node or browserify or anything else that uses CommonJS.

Note that even if you included react-bootstrap/index.js directly, you'll still be headed down a path of sadness, since that is an AMD file, not a CommonJS file.

So either convince react-bootstrap to use UMD instead of AMD in their pre-built file, or use a non-bower version of react-bootstrap (possibly the npm version?), or try to figure out the exact right deamdify+debowerify+shim combination to trick the bower version into playing nice :)

@EvanCarroll
Copy link
Author

Can we at least fail intelligibly? Is it possible in this situation?

@bobthecow
Copy link
Collaborator

It has nothing to do with debowerify, and everything to do with the fact that calling require() on a non-CommonJS file just doesn't work. And it's not debowerify's place to catch that, even if it is possible. This issue is why deamdify exists, and you might have some luck using that :)

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

2 participants