This repository was archived by the owner on Jun 26, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
This repository was archived by the owner on Jun 26, 2020. It is now read-only.
Discussion: Re-architect DevTools #1214
Copy link
Copy link
Closed
Labels
Description
The problem
React DevTools currently support all "recent" versions of React (14+? 13+?). As the React API grows and changes, this will become increasingly difficult to maintain. Several recent changes to React core have broken parts of DevTools (e.g. the profiler) without us even being aware.
DevTools exists as a separate project because it supports multiple versions of React. However this makes automated testing and type-checking more difficult (see #1209).
Possible solution
- Extract most of the current "backend" and "frontend" code pieces into a new package, e.g.
react-devtools-interface
, and move this package to the React repo.. - Release an initial version of
react-devtools-interface
that supports all of the currently supported versions of React (14+? 13+?). - Remove all legacy code from
react-devtools-interface
so that it only supports a single version of React (e.g. the version it corresponds to in Git). - Reduce the
react-devtools
project to be a basic shell that detects which version(s) of React are currently present, and loads the correspondingreact-devtools-interface
package(s) at runtime1.
1: Actual runtime loaded code seems to be frowned upon by both Google and Mozilla, but we could bundle the needed versions of react-devtools-interface
along with the shell extension and have it swap between them based on the injected React version(s).
Benefits
- Size and complexity of DevTools drastically decreases.
- The cost of refactoring the React API and its internals decreases as a result.
- Moving
react-devtools-interface
to the React repo would us to have automated integration tests and Flow type checks. - Reducing complexity in the DevTools interface likely also results in improved performance.
- This offers us a nice opportunity to address longstanding tech debt in some older sections of DevTools.
Drawbacks
- Using DevTools with multiple versions of React would result in a larger download size for the extension. (We should be able to easily remain below the 200 MB size limit though.)
Open questions
- How would we support bug fixes (or version-agnostic additions) to DevTools if this required multiple packages to be updated and released? (Could we automated this somehow?)
-
How would we support multiple versions of React on a single page?The shell wrapper would require some minimal UI for its loading state anyway. Maybe this UI could also handle multiple React versions by prompting you to select which version you want to inspect (and enable you to toggle this version later somehow)? -
How would this lazily-loaded package work for local development? (How would you iterate on it?)npm link
the localreact-devtools-interface
package while developing. - What would this mean for React-alike frameworks like Preact?
empyrical, ilovedesert001, NE-SmallTown, Jessidhia and herodrigues