-
Notifications
You must be signed in to change notification settings - Fork 1
Description
I give up. It's impossible to make React play nice with AMD. I was trying to use AMD because it's the de-facto standard for the browser, but it doesn't work with React.
The reason why it doesn't work is because RequireJS doesn't understand JSX scripts. Not without using some unofficial/unsupported JSXTransformer version. If we threw away the JSXTransformer it would work but we cannot force our users to run react-tools during development.
I also tried to not to use RequireJS for components, just for libraries. But that also doesn't work.. because the components would have to have dependencies on the libraries and it's impossible to load these dependencies synchronously while rendering the components. RequireJS doesn't have a sync-mode.
So, after hours and hours trying to figure this out, I found out Facebook doesn't use AMD, they use CommonJS. More specifically Browserify (http://browserify.org/). Instagram uses Browserify too. In fact, ReactRouter, which is the possibly most popular React component outside Facebook, also uses CommonJS. Here's a component declaration example: https://github.com/rackt/react-router/blob/master/modules/components/RouteHandler.js
So, I'm moving to Browserify and I'll update React-Components to use the exact same structure as ReactRouter.