1

I am using reagent 0.5.0 which depends on cljsjs/react. The latter comes with the following deps.cljs

{:foreign-libs [{
 :file "cljsjs/development/react.inc.js",
 :file-min "cljsjs/production/react.min.inc.js",
 :provides ["cljsjs.react"]}],
 :externs ["cljsjs/common/react.ext.js"]}

which makes the React's JavaScript end up in the compiler output.

I would like to prevent this from happening, because I also want to use React in plain JavaScript pages.

Besides, reagent/core.cljs has a :require [cljsjs.react] directive (To force the inclusion?) so the dependency cannot simply be omitted.

Is there a way to prevent React from ending up in the compiler output?

Andreas Steffan
  • 6,039
  • 2
  • 23
  • 25
  • Is there a reason you couldn't use the bundled react.js in your native JS code? I think it exports to `window`, so you should be able to use it that way. – skrat May 20 '15 at 10:32
  • I would prefer not to have native JS depend on output generated by the ClojureScript compiler. In fact, I would like to have ClojureScript compiled code and native JS depend on a webjars version of React. Still, I might end up doing what you suggest if there is no alternative. – Andreas Steffan May 20 '15 at 15:25

1 Answers1

1

From the Reagent Readme (https://github.com/reagent-project/reagent):

If you want the version of React with addons, you'd use something like this instead:

[reagent "0.5.0" :exclusions [cljsjs/react]]
[cljsjs/react-with-addons "0.12.2-4"]

If you want to use your own build of React (or React from a CDN), you have to use :exclusions variant of the dependency, and also provide a file named "cljsjs/react.cljs", containing just (ns cljsjs.react), in your project.

So, just use the :exclusions option in your dependencies, and provide your own cljsjs/react namespace and your good to go. It's up to you at that point to ensure React is loaded before Reagent however.

August Lilleaas
  • 54,010
  • 13
  • 102
  • 111
Walton Hoops
  • 864
  • 4
  • 14