Currently there's a lot of forking going on which makes it harder to figure out how everything fits together. For example: * Injecting into the hook - React tries to do this [here](https://github.com/facebook/react/blob/b49611e643fd6baa5214b9ebaae347f185c4ad5b/src/renderers/native/ReactNativeStack.js#L53-L79) - But actually the hook doesn't exist yet until [injected](https://github.com/facebook/react-native/blob/75c14e3674e90a9b67335b896c39d3618fb37ac1/Libraries/Core/Devtools/setupDevtools.js#L70) so RN just copies the same code [here](https://github.com/facebook/react-native/blob/75c14e3674e90a9b67335b896c39d3618fb37ac1/Libraries/Core/Devtools/setupDevtools.js#L76-L96) * Setting up the connection - Happens [here](https://github.com/facebook/react-native/blob/75c14e3674e90a9b67335b896c39d3618fb37ac1/Libraries/Core/Devtools/setupDevtools.js#L25-L45) in RN - However Electron shell has [very similar code](https://github.com/facebook/react-devtools/blob/5261d3af67050154e2c021db18aa0bad2b951af0/backend/websocketConnect.js#L14-L42) * Nuclide [vendors the Electron build](https://github.com/facebook/nuclide/tree/master/pkg/nuclide-react-inspector/VendorLib/dev-tools/build) for the Inspector (although it only uses the client while RN runs its fork of the server). * [Backends](https://github.com/facebook/react-devtools/tree/master/backend) depend on React internals but aren’t colocated with React --- The goals for consolidation: * Reduce the number of forks to make it easier to make changes across them (e.g. to support Fiber). * Make it easy for downstream packages (RN, Nuclide) to accept changes related to DevTools by packaging them. * Consolidate the code relying on React internal data structure inside the React repo. The plan for consolidation: - [x] Publish `react-devtools` package added in #487 - [x] Publish `react-devtools-core` separately - [x] Make [`nuclide-react-inspector`](https://github.com/facebook/nuclide/tree/master/pkg/nuclide-react-inspector) depend on it instead of vendoring its build (https://github.com/facebook/nuclide/pull/1016) - [x] Rewrite RN [`setupDevtools()`](https://github.com/facebook/react-native/blob/master/Libraries/Core/Devtools/setupDevtools.js) - [x] Use [the server from `react-devtools`](https://github.com/facebook/react-devtools/blob/5261d3af67050154e2c021db18aa0bad2b951af0/backend/websocketConnect.js#L14-L42) instead of a fork (WIP: https://github.com/facebook/react-devtools/pull/494) - [x] Remove [the late hook call](https://github.com/facebook/react-native/blob/75c14e3674e90a9b67335b896c39d3618fb37ac1/Libraries/Core/Devtools/setupDevtools.js#L75-L96) since the hook would already exist by the time React calls it (https://github.com/facebook/react-devtools/pull/494) - [x] Add a way to inject `resolveStyle` in it (https://github.com/facebook/react-devtools/pull/494) - [x] Pick up changes to the server introduced in RN: - [x] Make sure we don’t regress on https://github.com/facebook/react-native/commit/d0a26a75fb5d2740b93e3960cd6bbd13f11a8c88 - [x] Try to reconnect automatically https://github.com/facebook/react-native/commit/9a93a3cba47722a590a8912a5ace1c479eb4178a - [x] Do we need `attach:agent`? https://github.com/facebook/react-native/commit/9e4af68d91b3c5a321627bd393e4a3991bf94db1#diff-31cd378efa6368c1a37db84beec02002R46 - [x] Fix RN WebSocket race condition https://github.com/facebook/react-native/pull/12305 - [x] <s>(Maybe) don't reconnect if we started unconnected?</s> Meh - [x] Try to add backwards compat to `react-devtools-core@2.0` so it works with old clients (stable RN) - [x] Remove outdated wording (like "touch the app for bridge to work") which doesn't make sense anymore - [x] <s>Maybe Fix Fiber specific stuff?</s> Later, too much of it - [x] <s>Test on Android simulator</s> Somebody help plz - [x] Actually send a diff for depending on `react-devtools-core` https://github.com/facebook/react-native/pull/12316 - [x] Bump Nuclide inspector to use `react-devtools-core@2.0.2` https://github.com/facebook/nuclide/pull/1021 - [x] Figure out why Relay plugin is crashing - [ ] Move (current) backends into React repo - [ ] Fix Fiber DevTools - [x] `topsecret-RTView` - [x] Editing styles - [ ] Inspector (dirty solution: https://github.com/facebook/react-native/pull/12421) - [ ] Fix RN Inspector internal dependencies on React: - [ ] https://github.com/facebook/react-native/blob/a54d449e947afc609a404a699494902823fbbf5e/Libraries/Inspector/Inspector.js#L133-L134 - [ ] https://github.com/facebook/react-native/blob/a54d449e947afc609a404a699494902823fbbf5e/Libraries/Inspector/InspectorUtils.js#L18
Currently there's a lot of forking going on which makes it harder to figure out how everything fits together. For example:
Injecting into the hook
Setting up the connection
Nuclide vendors the Electron build for the Inspector (although it only uses the client while RN runs its fork of the server).
Backends depend on React internals but aren’t colocated with React
The goals for consolidation:
The plan for consolidation:
react-devtoolspackage added in Add npm package for standalone devtools app #487react-devtools-coreseparatelynuclide-react-inspectordepend on it instead of vendoring its build ([React Inspector] Replace vendored React DevTools with npm package facebookarchive/nuclide#1016)setupDevtools()react-devtoolsinstead of a fork (WIP: Add connectToDevTools(options) for React Native #494)resolveStylein it (Add connectToDevTools(options) for React Native #494)attach:agent? react/react-native@9e4af68#diff-31cd378efa6368c1a37db84beec02002R46(Maybe) don't reconnect if we started unconnected?Mehreact-devtools-core@2.0so it works with old clients (stable RN)Maybe Fix Fiber specific stuff?Later, too much of itTest on Android simulatorSomebody help plzreact-devtools-core[React DevTools] Move DevTools integration into its own repo react/react-native#12316react-devtools-core@2.0.2[React Inspector] Bump react-devtools-core facebookarchive/nuclide#1021topsecret-RTView