12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- 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)
|