jsdf/coffee-react-transform — pull request #10 by rmosolgo (2014-06-08 13:12:17+00:00)
Title: Add browserify, build single-page CJSXTransformer

It would be nice to have a single-page CJSXTransformer, like the single-page JSXTransformer used in react-rails: https://github.com/reactjs/react-rails/blob/master/lib/react/jsx.rb#L27

I'm not browserify wizard but I saw that's what React uses and @dobrite put it on my radar with his single-page CJSX transformer: https://github.com/dobrite/cjsx-transform

What do you think, could this be part of this project?

The only problem I had was getting the object into the global scope for _both_ ExecJS and browser environments. Here's what I found, is there anything else I can try?

Just setting `global.CJSXTransformer` didn't work because CoffeeScript (trying to be helpful) would assume you meant `window`, and wrap your code like this:

```javascript
(function (global){
// global would just turn out to be {} :(
}).call(this,typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
```

And `window.CJSXransformer` wouldn't work because (presumably) there's no `window` in ExecJS. I got errors like `ExecJS::ProgramError:ReferenceError: CJSXTransformer is not defined`.

I struggled a bit, then remembered a trick I saw [in the batman.js source](https://github.com/batmanjs/batman/blob/master/src/namespace.coffee#L19). Now, it's working ok (see [PR in `react-rails`](https://github.com/reactjs/react-rails/pull/47))