Skip to content

Commit

Permalink
[DevTools] remove backend dependency from the global hook (#26563)
Browse files Browse the repository at this point in the history
## Summary

- #26234 is reverted and replaced with a better approach
- introduce a new global devtools variable to decouple the global hook's
dependency on backend/console.js, and add it to react-devtools-inline
and react-devtools-standalone

With this PR, I want to introduce a new principle to hook.js: we should
always be alert when editing this file and avoid importing from other
files.
In the past, we try to inline a lot of the implementation because we use
`.toString()` to inject this function from the extension (we still have
some old comments left). Although it is no longer inlined that way, it
has became now more important to keep it clean as it is a de facto
global API people are using (9.9K files contains it on Github search as
of today).

**File size change for extension:**
Before:
379K installHook.js

After:
 21K installHook.js
363K renderer.js

DiffTrain build for commit dd53658.
  • Loading branch information
mondaychen committed Apr 7, 2023
1 parent 020147d commit d7d7716
Show file tree
Hide file tree
Showing 13 changed files with 19 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23888,7 +23888,7 @@ function createFiberRoot(
return root;
}

var ReactVersion = "18.3.0-next-85bb7b685-20230406";
var ReactVersion = "18.3.0-next-dd5365878-20230407";

// Might add PROFILE later.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8688,7 +8688,7 @@ var devToolsConfig$jscomp$inline_1028 = {
throw Error("TestRenderer does not support findFiberByHostInstance()");
},
bundleType: 0,
version: "18.3.0-next-85bb7b685-20230406",
version: "18.3.0-next-dd5365878-20230407",
rendererPackageName: "react-test-renderer"
};
var internals$jscomp$inline_1220 = {
Expand Down Expand Up @@ -8719,7 +8719,7 @@ var internals$jscomp$inline_1220 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "18.3.0-next-85bb7b685-20230406"
reconcilerVersion: "18.3.0-next-dd5365878-20230407"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_1221 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9114,7 +9114,7 @@ var devToolsConfig$jscomp$inline_1070 = {
throw Error("TestRenderer does not support findFiberByHostInstance()");
},
bundleType: 0,
version: "18.3.0-next-85bb7b685-20230406",
version: "18.3.0-next-dd5365878-20230407",
rendererPackageName: "react-test-renderer"
};
var internals$jscomp$inline_1261 = {
Expand Down Expand Up @@ -9145,7 +9145,7 @@ var internals$jscomp$inline_1261 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "18.3.0-next-85bb7b685-20230406"
reconcilerVersion: "18.3.0-next-dd5365878-20230407"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_1262 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ if (
}
"use strict";

var ReactVersion = "18.3.0-next-85bb7b685-20230406";
var ReactVersion = "18.3.0-next-dd5365878-20230407";

// ATTENTION
// When adding new symbols to this file,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -639,4 +639,4 @@ exports.useSyncExternalStore = function (
);
};
exports.useTransition = useTransition;
exports.version = "18.3.0-next-85bb7b685-20230406";
exports.version = "18.3.0-next-dd5365878-20230407";
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ exports.useSyncExternalStore = function (
);
};
exports.useTransition = useTransition;
exports.version = "18.3.0-next-85bb7b685-20230406";
exports.version = "18.3.0-next-dd5365878-20230407";

/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
if (
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
85bb7b685b7aec50879703b94dd31523cf69b34d
dd5365878da2fe88a34dcdbb07d8297a78841da4
Original file line number Diff line number Diff line change
Expand Up @@ -27184,7 +27184,7 @@ function createFiberRoot(
return root;
}

var ReactVersion = "18.3.0-next-85bb7b685-20230406";
var ReactVersion = "18.3.0-next-dd5365878-20230407";

function createPortal$1(
children,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9555,7 +9555,7 @@ var roots = new Map(),
devToolsConfig$jscomp$inline_1052 = {
findFiberByHostInstance: getInstanceFromNode,
bundleType: 0,
version: "18.3.0-next-85bb7b685-20230406",
version: "18.3.0-next-dd5365878-20230407",
rendererPackageName: "react-native-renderer",
rendererConfig: {
getInspectorDataForViewTag: function () {
Expand Down Expand Up @@ -9597,7 +9597,7 @@ var internals$jscomp$inline_1297 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "18.3.0-next-85bb7b685-20230406"
reconcilerVersion: "18.3.0-next-dd5365878-20230407"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_1298 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10264,7 +10264,7 @@ var roots = new Map(),
devToolsConfig$jscomp$inline_1130 = {
findFiberByHostInstance: getInstanceFromNode,
bundleType: 0,
version: "18.3.0-next-85bb7b685-20230406",
version: "18.3.0-next-dd5365878-20230407",
rendererPackageName: "react-native-renderer",
rendererConfig: {
getInspectorDataForViewTag: function () {
Expand Down Expand Up @@ -10319,7 +10319,7 @@ var roots = new Map(),
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "18.3.0-next-85bb7b685-20230406"
reconcilerVersion: "18.3.0-next-dd5365878-20230407"
});
exports.createPortal = function (children, containerTag) {
return createPortal$1(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27705,7 +27705,7 @@ function createFiberRoot(
return root;
}

var ReactVersion = "18.3.0-next-85bb7b685-20230406";
var ReactVersion = "18.3.0-next-dd5365878-20230407";

function createPortal$1(
children,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9815,7 +9815,7 @@ var roots = new Map(),
devToolsConfig$jscomp$inline_1107 = {
findFiberByHostInstance: getInstanceFromTag,
bundleType: 0,
version: "18.3.0-next-85bb7b685-20230406",
version: "18.3.0-next-dd5365878-20230407",
rendererPackageName: "react-native-renderer",
rendererConfig: {
getInspectorDataForViewTag: function () {
Expand Down Expand Up @@ -9857,7 +9857,7 @@ var internals$jscomp$inline_1359 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "18.3.0-next-85bb7b685-20230406"
reconcilerVersion: "18.3.0-next-dd5365878-20230407"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_1360 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10524,7 +10524,7 @@ var roots = new Map(),
devToolsConfig$jscomp$inline_1185 = {
findFiberByHostInstance: getInstanceFromTag,
bundleType: 0,
version: "18.3.0-next-85bb7b685-20230406",
version: "18.3.0-next-dd5365878-20230407",
rendererPackageName: "react-native-renderer",
rendererConfig: {
getInspectorDataForViewTag: function () {
Expand Down Expand Up @@ -10579,7 +10579,7 @@ var roots = new Map(),
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "18.3.0-next-85bb7b685-20230406"
reconcilerVersion: "18.3.0-next-dd5365878-20230407"
});
exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = {
computeComponentStackForErrorReporting: function (reactTag) {
Expand Down

0 comments on commit d7d7716

Please sign in to comment.