boot-clj clojurescript project w/ reagent and react-with-addons?

164 Views Asked by At

Is anyone familiar with using boot-clj and cljsjs to package react-with-addons inside a reagent project? Reagent already requires react, so you have to explicitly list exclusions as noted here. Despite doing this, the build process is always outputting react.inc.js instead of react-with-addons.inc.js. Here is my boot file…

  [reagent "0.6.0-alpha" :exclusions [cljsjs/react cljsjs/react-dom cljsjs/react-dom-server]]
  ,,,[cljsjs/react-with-addons "15.1.0-0"]
  ,,,[cljsjs/react-dom "15.1.0-0"]
  ,,,[cljsjs/react-dom-server "15.1.0-0"]

If I look at the reagent build process, it seems to require r-dom and r-dom/server via cljsjs packages but then provide its own react from a webpack build:

  :dependencies [[org.clojure/clojure "1.8.0"]
                 [org.clojure/clojurescript "1.8.51"]
                 [cljsjs/react-dom "15.2.1-0"]
                 [cljsjs/react-dom-server "15.2.1-0”]]

  …
  :webpack {:cljsbuild
             {:builds {:client
                       {:compiler
                        {:foreign-libs
                         [{:file "target/webpack/bundle.js"
                           :file-min "target/webpack/bundle.min.js"
                           :provides ["cljsjs.react.dom"
                                      "cljsjs.react.dom.server"
                                      "cljsjs.react"]
                           :requires []}]}}}}}

If anyone can shed some insight as to why boot continues to pull in the non-with-addons react I would be greatly appreciative.

1

There are 1 best solutions below

0
On

Well, I hope my hours of work help someone down the road.

The solution is thus:

          [reagent "0.6.0-alpha" :exclusions [cljsjs/react cljsjs/react-dom cljsjs/react-dom-server]]
          ,,,[cljsjs/react-with-addons "15.1.0-0"]
          ;; boot show -d illuminates that react-dom requires react, but we want to use react-with-addons
          ,,,[cljsjs/react-dom "15.1.0-0" :exclusions [cljsjs/react]]
          ,,,[cljsjs/react-dom-server "15.1.0-0" :exclusions [cljsjs/react]]

It turns out react-dom and dom-server had transient dependencies that were pulling in the incorrect react version. Explicitly excluding them fixed the issue, and with-addons is correctly packaged.