Skip to content
This repository was archived by the owner on Jun 26, 2020. It is now read-only.
This repository was archived by the owner on Jun 26, 2020. It is now read-only.

Discussion: Re-architect DevTools #1214

@bvaughn

Description

@bvaughn

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

  1. 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..
  2. Release an initial version of react-devtools-interface that supports all of the currently supported versions of React (14+? 13+?).
  3. 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).
  4. Reduce the react-devtools project to be a basic shell that detects which version(s) of React are currently present, and loads the corresponding react-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

  1. Size and complexity of DevTools drastically decreases.
  2. The cost of refactoring the React API and its internals decreases as a result.
  3. Moving react-devtools-interface to the React repo would us to have automated integration tests and Flow type checks.
  4. Reducing complexity in the DevTools interface likely also results in improved performance.
  5. This offers us a nice opportunity to address longstanding tech debt in some older sections of DevTools.

Drawbacks

  1. 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 local react-devtools-interface package while developing.
  • What would this mean for React-alike frameworks like Preact?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions