2016-11-15 16:12:00 +03:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
|
2016-01-20 21:00:30 +03:00
|
|
|
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.
|
2015-09-30 05:40:00 +03:00
|
|
|
|
2016-01-20 21:00:30 +03:00
|
|
|
First, clone the repo and get ready to build it. Replace `<version>`
|
|
|
|
with the version tag you are targetting:
|
2016-01-20 00:55:06 +03:00
|
|
|
|
2016-01-20 21:00:30 +03:00
|
|
|
* 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:
|
2015-09-30 05:40:00 +03:00
|
|
|
|
|
|
|
* npm install
|
|
|
|
* grunt build
|
2016-01-20 21:00:30 +03:00
|
|
|
|
|
|
|
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
|
2016-11-28 16:38:00 +03:00
|
|
|
search/replace. There is only about ~14 places to change.
|
2016-01-20 21:00:30 +03:00
|
|
|
|
|
|
|
Now move into our repo (note the naming of `react-dev.js`, it's the dev version):
|
|
|
|
|
2016-01-20 00:55:06 +03:00
|
|
|
* cp build/react-with-addons.js <gecko-dev>/devtools/client/shared/vendor/react-dev.js
|
|
|
|
|
2016-01-20 21:00:30 +03:00
|
|
|
Now we need to generate a production version of React:
|
2015-10-23 23:19:41 +03:00
|
|
|
|
2015-09-30 05:40:00 +03:00
|
|
|
* NODE_ENV=production grunt build
|
2016-01-20 21:00:30 +03:00
|
|
|
|
|
|
|
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:
|
|
|
|
|
2015-09-30 05:40:00 +03:00
|
|
|
* cp build/react-with-addons.js <gecko-dev>/devtools/client/shared/vendor/react.js
|
|
|
|
|
2016-12-01 21:47:36 +03:00
|
|
|
You also need to copy the ReactDOM and ReactDOMServer package. It requires React, so
|
2015-10-30 17:06:52 +03:00
|
|
|
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)
|
2016-12-01 21:47:36 +03:00
|
|
|
* cp build/react-dom.js <gecko-dev>/devtools/client/shared/vendor/react-dom-server.js
|
|
|
|
* (change `require('react')` at the top of the file to the right path)
|