This dates back to over a year ago, but here's what I did to use React
15.1.0 from a CDN when using Reagent 0.7:
My Reagent dependency in project.clj looks like this:
[reagent "0.7.0" :exclusions [cljsjs/react
cljsjs/react-dom
cljsjs/react-dom-server]]
Then I just created a set of dummy namespaces in my source tree to fake out
the compiler:
solace:eris2 jfischer$ find src/cljsjs
src/cljsjs
src/cljsjs/react.cljs
src/cljsjs/react
src/cljsjs/react/dom.cljs
src/cljsjs/react/dom
src/cljsjs/react/dom/server.cljs
solace:eris2 jfischer$ cat src/cljsjs/react.cljs
(ns cljsjs.react
"Dummy namespace to let me exclude React from my compiled output.")
And in my HTML loaded React from the CDN:
<script src="https://unpkg.com/[email protected]/dist/react.min.js"></script>
<script
src="https://unpkg.com/[email protected]/dist/react-dom.min.js"></script>
On Monday, March 5, 2018 at 11:02:53 PM UTC-8, [email protected] wrote:
>
> Hi all,
>
> I want to use reagent 0.8 with an external React 16, available as
> `window.React` (equivalent to using React from a CDN, but in reality built
> and exported from a separate webpack bundle).
>
> My goal is to build a bundle which uses React, ReactDOM and
> createReactClass from the window object, instead of inlining its own copies
> of those libraries.
>
> I talked to @Deraen about this on Slack a couple of months ago who helped
> me get this working. I'm currently able to build a bundle as described
> above, but I have to vendor in all the extern files from the relevant
> cljsjs React libraries, and add them to :exclusions. My :compiler key in my
> cljsbuild config looks like this:
>
> :foreign-libs [{:file "src/js/empty.js"
> :provides ["react" "react-dom" "create-react-class"
> "react-dom/server"]
> :requires []
> :global-exports {react React
> react-dom ReactDOM
> create-react-class createReactClass
> react-dom/server ReactDOMServer}}]
> :externs ["src/js/externs/react.ext.js"
> "src/js/externs/react-dom.ext.js"
> "src/js/externs/create-react-class.ext.js"]
>
> He thought at the time that it should be possible without the externs and
> :exclusions, as mentioned on this page:
> https://github.com/reagent-project/reagent/blob/master/docs/0.8-upgrade.md#browser---loading-react-from-cdnjs-or-custom-webpack-bundle
>
> > it should be possible to override the Cljsjs foreign-libs, while still
> using externs from Cljsjs packages.
>
> But I can't figure it out - if I don't exclude the cljsjs libraries, I get
> a bundle with React 15 built-in, and if I do exclude them, the bundle is
> broken because the externs are missing and the names get eaten by the
> closure compiler.
>
> Is there any way around having to commit the externs?
>
> Thanks,
> Alex
>
>
--
Note that posts from new members are moderated - please be patient with your
first post.
---
You received this message because you are subscribed to the Google Groups
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/clojurescript.