JedWatson / react-component-gulp-tasks

Common Gulp tasks I use across my React Component projects
MIT License
112 stars 42 forks source link

Output dist doesn't work in AMD environments because of browserify-shim #8

Open pixeldrew opened 9 years ago

pixeldrew commented 9 years ago

browserify-shim incorrectly rewrites require('react') to (window.React).

in a new version of browserify-shim, it rewrites to this (which is still broken):

var React = (typeof window !== "undefined" ? window.React : typeof global !== "undefined" ? global.React : null);

This might not be a bug but by the design of browserify-shim. It should be mentioned in your docs that the output of react-components-gulp-tasks will not be A/UMD compatible.

I was able to successfully make a UMD build using webpack.

mondaychen commented 8 years ago

+1 for this. I tried to use https://github.com/JedWatson/react-select in my AMD project and met the same problem. A tip for anyone who needs UMD support, I was able to do it with this: https://github.com/mondaychen/react-select/commit/f6c87d2f8081e04afc8c3749c590484c2efe09af . Probably not the best way but works.

jochenberger commented 7 years ago

I tried to rewrite this library to use https://github.com/eduardolundgren/gulp-umd instead of browserify-shim, but couldn't get it to work. I always end up with an empty file as dist-script. I can however create a PR with what I have, maybe someone who is more experienced with node and gulp can tell me what I'm doing wrong.

jochenberger commented 7 years ago

See #25