thlorenz / browserify-shim

📩 Makes CommonJS incompatible files browserifyable.
MIT License
933 stars 87 forks source link

Add tips to README on conditional shimming #158

Closed fatso83 closed 9 years ago

fatso83 commented 9 years ago

This might seem superfluous, but from browsing the issues history it seems that a common thing to want is conditional shimming. Meaning you would like to shim some dependencies given some conditions, while in other cases you would like them baked in. Typically in build setups with multiple targets. This could also probably appease some of the needs of the one's wanting to do inline transforms. From the comments in some of the issues it seemed like one way of doing this would be to rewrite the external shim config file based on these conditions, but once I realized we are just talking about a normal CommonJS package the sky's the limit, so to speak, when it comes to ways of approaching this.

So maybe you could add a tip to the README on ways of achieving this? A quick hack, just to test out the concept, was for me to check for a condition in my gulpfile.js and set a global flag SHOULD_SHIM based on that. I would check for that in shim-config.js and configure the module's exports based on that.

bendrucker commented 9 years ago

A PR is welcome

fatso83 commented 9 years ago

Can def look into doing that. I thought I'd just propose the idea before making a PR. Thanks.