Update 0.8-upgrade.md

This commit is contained in:
Juho Teperi 2018-01-09 14:18:23 +02:00 committed by GitHub
parent 035ba9cf29
commit 26858c3df3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 26 additions and 1 deletions

View File

@ -26,7 +26,32 @@ builds. ClojureScript compiler will automatically set this constant to
`production` value when using `:advanced` optimizations. This enables `production` value when using `:advanced` optimizations. This enables
the React production build. the React production build.
## NodeJS ## Browser - loading React from CDNJS or custom Webpack bundle
**TODO: Not tested properly**
If you want to load React.js yourself from external JS file (CDN) or from custom bundle,
it should be possible to override the Cljsjs foreign-libs, while still using externs from Cljsjs packages. To override the foreign-libs, you can provide following compiler option:
```clj
:foreign-libs
[{:file "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}}]
```
You'll also need to create the mentioned `empty.js` file (FIXME: relative to `project.clj`?).
If your bundle provides other libraries, you could extern `:provides` and `:global-exports` (e.g. `prop-types`).
## NodeJS - Cljsjs
Requires https://github.com/clojure/clojurescript/commit/f7d611d87f6ea8a605eae7c0339f30b79a840b49
Reagent should use Cljsjs libraries by default even when running on Node.
## NodeJS - node modules
Install `react`, `react-dom` and `create-react-class` npm packages, Install `react`, `react-dom` and `create-react-class` npm packages,
and ClojureScript should automatically use `require` to and ClojureScript should automatically use `require` to