REACT_UPGRADING 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. We use a version of React that has a few minor tweaks. We want to use
  2. an un-minified production version anyway, and because of all of this
  3. you need to build React yourself to upgrade it for devtools.
  4. First, clone the repo and get ready to build it. Replace `<version>`
  5. with the version tag you are targetting:
  6. * git clone https://github.com/facebook/react.git
  7. * cd react
  8. * git checkout <version>
  9. * In `src/addons/ReactWithAddons.js`, move the
  10. `React.addons.TestUtils = ...` line outside of the `if`
  11. block to force it be include in the production build
  12. Next, build React:
  13. * npm install
  14. * grunt build
  15. Unfortunately, you need to manually patch the generated JS file. We
  16. need to force React to always create HTML elements, and we do this by
  17. changing all `document.createElement` calls to `createElementNS`. It's
  18. much easier to do this on the generated file to make sure you update
  19. all dependencies as well.
  20. Open `build/react-with-addons.js` and search for all
  21. `document.createElement` calls and replace them with
  22. `document.createElementNS('http://www.w3.org/1999/xhtml', ...)`. Note
  23. that some code is `ownerDocument.createElement` so don't do a blind
  24. search/replace. There is only about ~12 places to change.
  25. Now move into our repo (note the naming of `react-dev.js`, it's the dev version):
  26. * cp build/react-with-addons.js <gecko-dev>/devtools/client/shared/vendor/react-dev.js
  27. Now we need to generate a production version of React:
  28. * NODE_ENV=production grunt build
  29. Unfortunately, you need to manually replace all the `createElement`
  30. calls in this version again. We know this is not ideal but WE NEED TO
  31. MOVE OFF XUL and we don't need to do this anymore once that happens.
  32. After patching `build/react-with-addons.js` again, copy the production
  33. version over:
  34. * cp build/react-with-addons.js <gecko-dev>/devtools/client/shared/vendor/react.js
  35. You also need to copy the ReactDOM package. It requires React, so
  36. right now we are just manually changing the path from `react` to
  37. `devtools/client/shared/vendor/react`.
  38. * cp build/react-dom.js <gecko-dev>/devtools/client/shared/vendor/react-dom.js
  39. * (change `require('react')` at the top of the file to the right path)