summaryrefslogtreecommitdiffstats
path: root/devtools/client/shared/vendor/REACT_UPGRADING
blob: a82b4fa8cf2da2e254dedf5e67b666606211454d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
We use a version of React that has a few minor tweaks. We want to use
an un-minified production version anyway, and because of all of this
you need to build React yourself to upgrade it for devtools.

First, clone the repo and get ready to build it. Replace `<version>`
with the version tag you are targetting:

* git clone https://github.com/facebook/react.git
* cd react
* git checkout <version>
* In `src/addons/ReactWithAddons.js`, move the
  `React.addons.TestUtils = ...` line outside of the `if`
  block to force it be include in the production build

Next, build React:

* npm install
* grunt build

Unfortunately, you need to manually patch the generated JS file. We
need to force React to always create HTML elements, and we do this by
changing all `document.createElement` calls to `createElementNS`. It's
much easier to do this on the generated file to make sure you update
all dependencies as well.

Open `build/react-with-addons.js` and search for all
`document.createElement` calls and replace them with
`document.createElementNS('http://www.w3.org/1999/xhtml', ...)`. Note
that some code is `ownerDocument.createElement` so don't do a blind
search/replace. There is only about ~12 places to change.

Now move  into our repo (note the naming of `react-dev.js`, it's the dev version):

* cp build/react-with-addons.js <gecko-dev>/devtools/client/shared/vendor/react-dev.js

Now we need to generate a production version of React:

* NODE_ENV=production grunt build

Unfortunately, you need to manually replace all the `createElement`
calls in this version again. We know this is not ideal but WE NEED TO
MOVE OFF XUL and we don't need to do this anymore once that happens.

After patching `build/react-with-addons.js` again, copy the production
version over:

* cp build/react-with-addons.js <gecko-dev>/devtools/client/shared/vendor/react.js

You also need to copy the ReactDOM package. It requires React, so
right now we are just manually changing the path from `react` to
`devtools/client/shared/vendor/react`.

* cp build/react-dom.js <gecko-dev>/devtools/client/shared/vendor/react-dom.js
* (change `require('react')` at the top of the file to the right path)