Quick tip – Build React into your Dojo apps

So I spent some time this past weekend fussing around with getting a Dojo app built with React. I was going through and replacing use of Dijits for React components. Everything was working just fine in development. It was awesome!

Then I tried to build it with the Dojo build system and none of the React stuff worked. Bummer.

So React is is built with a UMD wrapper, as many good libraries are. So it will work with AMD loaders like RequireJS and Dojo. Something with the build was off though. It was getting wrapped in a define method and my React imports were null. After some hair pulling, I went the Dojo IRC (always a good spot to get some solid Dojo info) and someone there pointed me in the right direction. Just tell the Dojo build system that those modules are AMD modules. Problem solved.

That was the light bulb moment I needed.

So I updated my Dojo build profile packages like this.

And voila!

My app compiled with the Dojo build into a single file with my React components and everything worked nicely.

So the point is, if you run into issues with UMD modules not compiling with the Dojo build system, use the resourceTags option to let the Dojo build to know to treat them like AMD modules.

Happy hacking!

Share on Google+0Tweet about this on TwitterShare on Facebook0Share on LinkedIn9Share on Reddit0