Skip to content

Commit 5d1b889

Browse files
committed
[compiler][poc] Quick experiment with SSR-optimization pass (#35102)
Just a quick poc: * Inline useState when the initializer is known to not be a function. The heuristic could be improved but will handle a large number of cases already. * Prune effects * Prune useRef if the ref is unused, by pruning 'ref' props on primitive components. Then DCE does the rest of the work - with a small change to allow `useRef()` calls to be dropped since function calls aren't normally eligible for dropping. * Prune event handlers, by pruning props whose names start w "on" from primitive components. Then DCE removes the functions themselves. Per the fixture, this gets pretty far. --- [//]: # (BEGIN SAPLING FOOTER) Stack created with [Sapling](https://sapling-scm.com). Best reviewed with [ReviewStack](https://reviewstack.dev/facebook/react/pull/35102). * #35112 * __->__ #35102 DiffTrain build for [4cf770d](4cf770d)
1 parent d6637c6 commit 5d1b889

23 files changed

+516
-88
lines changed

compiled-rn/VERSION_NATIVE_FB

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
19.3.0-native-fb-7ee974de-20251120
1+
19.3.0-native-fb-4cf770d7-20251120

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOM-dev.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<05935f03d3df4d72912382568f8af775>>
10+
* @generated SignedSource<<50417dc1f8478cadb5d15ec66ce1c552>>
1111
*/
1212

1313
"use strict";
@@ -410,5 +410,5 @@ __DEV__ &&
410410
exports.useFormStatus = function () {
411411
return resolveDispatcher().useHostTransitionStatus();
412412
};
413-
exports.version = "19.3.0-native-fb-7ee974de-20251120";
413+
exports.version = "19.3.0-native-fb-4cf770d7-20251120";
414414
})();

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOM-prod.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<cee9ee4aa58d1c270cfb33434b073bf2>>
10+
* @generated SignedSource<<5a375e02c857ed9220d4ece0ad635a81>>
1111
*/
1212

1313
"use strict";
@@ -209,4 +209,4 @@ exports.useFormState = function (action, initialState, permalink) {
209209
exports.useFormStatus = function () {
210210
return ReactSharedInternals.H.useHostTransitionStatus();
211211
};
212-
exports.version = "19.3.0-native-fb-7ee974de-20251120";
212+
exports.version = "19.3.0-native-fb-4cf770d7-20251120";

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOM-profiling.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<cee9ee4aa58d1c270cfb33434b073bf2>>
10+
* @generated SignedSource<<5a375e02c857ed9220d4ece0ad635a81>>
1111
*/
1212

1313
"use strict";
@@ -209,4 +209,4 @@ exports.useFormState = function (action, initialState, permalink) {
209209
exports.useFormStatus = function () {
210210
return ReactSharedInternals.H.useHostTransitionStatus();
211211
};
212-
exports.version = "19.3.0-native-fb-7ee974de-20251120";
212+
exports.version = "19.3.0-native-fb-4cf770d7-20251120";

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMClient-dev.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<721ddca13a3acff24e6252d88a537546>>
10+
* @generated SignedSource<<45f413aba1979b613b798abfb1cd555e>>
1111
*/
1212

1313
/*
@@ -30244,11 +30244,11 @@ __DEV__ &&
3024430244
};
3024530245
(function () {
3024630246
var isomorphicReactPackageVersion = React.version;
30247-
if ("19.3.0-native-fb-7ee974de-20251120" !== isomorphicReactPackageVersion)
30247+
if ("19.3.0-native-fb-4cf770d7-20251120" !== isomorphicReactPackageVersion)
3024830248
throw Error(
3024930249
'Incompatible React versions: The "react" and "react-dom" packages must have the exact same version. Instead got:\n - react: ' +
3025030250
(isomorphicReactPackageVersion +
30251-
"\n - react-dom: 19.3.0-native-fb-7ee974de-20251120\nLearn more: https://react.dev/warnings/version-mismatch")
30251+
"\n - react-dom: 19.3.0-native-fb-4cf770d7-20251120\nLearn more: https://react.dev/warnings/version-mismatch")
3025230252
);
3025330253
})();
3025430254
("function" === typeof Map &&
@@ -30285,10 +30285,10 @@ __DEV__ &&
3028530285
!(function () {
3028630286
var internals = {
3028730287
bundleType: 1,
30288-
version: "19.3.0-native-fb-7ee974de-20251120",
30288+
version: "19.3.0-native-fb-4cf770d7-20251120",
3028930289
rendererPackageName: "react-dom",
3029030290
currentDispatcherRef: ReactSharedInternals,
30291-
reconcilerVersion: "19.3.0-native-fb-7ee974de-20251120"
30291+
reconcilerVersion: "19.3.0-native-fb-4cf770d7-20251120"
3029230292
};
3029330293
internals.overrideHookState = overrideHookState;
3029430294
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
@@ -30438,5 +30438,5 @@ __DEV__ &&
3043830438
listenToAllSupportedEvents(container);
3043930439
return new ReactDOMHydrationRoot(initialChildren);
3044030440
};
30441-
exports.version = "19.3.0-native-fb-7ee974de-20251120";
30441+
exports.version = "19.3.0-native-fb-4cf770d7-20251120";
3044230442
})();

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMClient-prod.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<884cca248a041b9acfc849338c44b385>>
10+
* @generated SignedSource<<7ab480c2a75621adfc7138f0c26b62c3>>
1111
*/
1212

1313
/*
@@ -17707,14 +17707,14 @@ ReactDOMHydrationRoot.prototype.unstable_scheduleHydration = function (target) {
1770717707
};
1770817708
var isomorphicReactPackageVersion$jscomp$inline_2054 = React.version;
1770917709
if (
17710-
"19.3.0-native-fb-7ee974de-20251120" !==
17710+
"19.3.0-native-fb-4cf770d7-20251120" !==
1771117711
isomorphicReactPackageVersion$jscomp$inline_2054
1771217712
)
1771317713
throw Error(
1771417714
formatProdErrorMessage(
1771517715
527,
1771617716
isomorphicReactPackageVersion$jscomp$inline_2054,
17717-
"19.3.0-native-fb-7ee974de-20251120"
17717+
"19.3.0-native-fb-4cf770d7-20251120"
1771817718
)
1771917719
);
1772017720
ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
@@ -17736,10 +17736,10 @@ ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
1773617736
};
1773717737
var internals$jscomp$inline_2636 = {
1773817738
bundleType: 0,
17739-
version: "19.3.0-native-fb-7ee974de-20251120",
17739+
version: "19.3.0-native-fb-4cf770d7-20251120",
1774017740
rendererPackageName: "react-dom",
1774117741
currentDispatcherRef: ReactSharedInternals,
17742-
reconcilerVersion: "19.3.0-native-fb-7ee974de-20251120"
17742+
reconcilerVersion: "19.3.0-native-fb-4cf770d7-20251120"
1774317743
};
1774417744
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
1774517745
var hook$jscomp$inline_2637 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
@@ -17846,4 +17846,4 @@ exports.hydrateRoot = function (container, initialChildren, options) {
1784617846
listenToAllSupportedEvents(container);
1784717847
return new ReactDOMHydrationRoot(initialChildren);
1784817848
};
17849-
exports.version = "19.3.0-native-fb-7ee974de-20251120";
17849+
exports.version = "19.3.0-native-fb-4cf770d7-20251120";

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMClient-profiling.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<c58b94d378317a8d4ed5f4201d8d5c08>>
10+
* @generated SignedSource<<6afb51a60e7fa24ef8e08ec9be4aa1ee>>
1111
*/
1212

1313
/*
@@ -19833,14 +19833,14 @@ ReactDOMHydrationRoot.prototype.unstable_scheduleHydration = function (target) {
1983319833
};
1983419834
var isomorphicReactPackageVersion$jscomp$inline_2369 = React.version;
1983519835
if (
19836-
"19.3.0-native-fb-7ee974de-20251120" !==
19836+
"19.3.0-native-fb-4cf770d7-20251120" !==
1983719837
isomorphicReactPackageVersion$jscomp$inline_2369
1983819838
)
1983919839
throw Error(
1984019840
formatProdErrorMessage(
1984119841
527,
1984219842
isomorphicReactPackageVersion$jscomp$inline_2369,
19843-
"19.3.0-native-fb-7ee974de-20251120"
19843+
"19.3.0-native-fb-4cf770d7-20251120"
1984419844
)
1984519845
);
1984619846
ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
@@ -19862,10 +19862,10 @@ ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
1986219862
};
1986319863
var internals$jscomp$inline_2376 = {
1986419864
bundleType: 0,
19865-
version: "19.3.0-native-fb-7ee974de-20251120",
19865+
version: "19.3.0-native-fb-4cf770d7-20251120",
1986619866
rendererPackageName: "react-dom",
1986719867
currentDispatcherRef: ReactSharedInternals,
19868-
reconcilerVersion: "19.3.0-native-fb-7ee974de-20251120",
19868+
reconcilerVersion: "19.3.0-native-fb-4cf770d7-20251120",
1986919869
getLaneLabelMap: function () {
1987019870
for (
1987119871
var map = new Map(), lane = 1, index$336 = 0;
@@ -19988,4 +19988,4 @@ exports.hydrateRoot = function (container, initialChildren, options) {
1998819988
listenToAllSupportedEvents(container);
1998919989
return new ReactDOMHydrationRoot(initialChildren);
1999019990
};
19991-
exports.version = "19.3.0-native-fb-7ee974de-20251120";
19991+
exports.version = "19.3.0-native-fb-4cf770d7-20251120";

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMProfiling-dev.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<4758064f6b5f733d40bb427098e9df8e>>
10+
* @generated SignedSource<<07c8159d7a1c7776304ee3e0a376def3>>
1111
*/
1212

1313
/*
@@ -30306,11 +30306,11 @@ __DEV__ &&
3030630306
};
3030730307
(function () {
3030830308
var isomorphicReactPackageVersion = React.version;
30309-
if ("19.3.0-native-fb-7ee974de-20251120" !== isomorphicReactPackageVersion)
30309+
if ("19.3.0-native-fb-4cf770d7-20251120" !== isomorphicReactPackageVersion)
3031030310
throw Error(
3031130311
'Incompatible React versions: The "react" and "react-dom" packages must have the exact same version. Instead got:\n - react: ' +
3031230312
(isomorphicReactPackageVersion +
30313-
"\n - react-dom: 19.3.0-native-fb-7ee974de-20251120\nLearn more: https://react.dev/warnings/version-mismatch")
30313+
"\n - react-dom: 19.3.0-native-fb-4cf770d7-20251120\nLearn more: https://react.dev/warnings/version-mismatch")
3031430314
);
3031530315
})();
3031630316
("function" === typeof Map &&
@@ -30347,10 +30347,10 @@ __DEV__ &&
3034730347
!(function () {
3034830348
var internals = {
3034930349
bundleType: 1,
30350-
version: "19.3.0-native-fb-7ee974de-20251120",
30350+
version: "19.3.0-native-fb-4cf770d7-20251120",
3035130351
rendererPackageName: "react-dom",
3035230352
currentDispatcherRef: ReactSharedInternals,
30353-
reconcilerVersion: "19.3.0-native-fb-7ee974de-20251120"
30353+
reconcilerVersion: "19.3.0-native-fb-4cf770d7-20251120"
3035430354
};
3035530355
internals.overrideHookState = overrideHookState;
3035630356
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
@@ -30816,7 +30816,7 @@ __DEV__ &&
3081630816
exports.useFormStatus = function () {
3081730817
return resolveDispatcher().useHostTransitionStatus();
3081830818
};
30819-
exports.version = "19.3.0-native-fb-7ee974de-20251120";
30819+
exports.version = "19.3.0-native-fb-4cf770d7-20251120";
3082030820
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
3082130821
"function" ===
3082230822
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMProfiling-prod.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<a00ace58dbad9c13447b42a7c8d34fae>>
10+
* @generated SignedSource<<f63c20ce5cfae6b826758a549607fcca>>
1111
*/
1212

1313
/*
@@ -17724,14 +17724,14 @@ ReactDOMHydrationRoot.prototype.unstable_scheduleHydration = function (target) {
1772417724
};
1772517725
var isomorphicReactPackageVersion$jscomp$inline_2055 = React.version;
1772617726
if (
17727-
"19.3.0-native-fb-7ee974de-20251120" !==
17727+
"19.3.0-native-fb-4cf770d7-20251120" !==
1772817728
isomorphicReactPackageVersion$jscomp$inline_2055
1772917729
)
1773017730
throw Error(
1773117731
formatProdErrorMessage(
1773217732
527,
1773317733
isomorphicReactPackageVersion$jscomp$inline_2055,
17734-
"19.3.0-native-fb-7ee974de-20251120"
17734+
"19.3.0-native-fb-4cf770d7-20251120"
1773517735
)
1773617736
);
1773717737
ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
@@ -17753,10 +17753,10 @@ ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
1775317753
};
1775417754
var internals$jscomp$inline_2639 = {
1775517755
bundleType: 0,
17756-
version: "19.3.0-native-fb-7ee974de-20251120",
17756+
version: "19.3.0-native-fb-4cf770d7-20251120",
1775717757
rendererPackageName: "react-dom",
1775817758
currentDispatcherRef: ReactSharedInternals,
17759-
reconcilerVersion: "19.3.0-native-fb-7ee974de-20251120"
17759+
reconcilerVersion: "19.3.0-native-fb-4cf770d7-20251120"
1776017760
};
1776117761
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
1776217762
var hook$jscomp$inline_2640 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
@@ -18016,4 +18016,4 @@ exports.useFormState = function (action, initialState, permalink) {
1801618016
exports.useFormStatus = function () {
1801718017
return ReactSharedInternals.H.useHostTransitionStatus();
1801818018
};
18019-
exports.version = "19.3.0-native-fb-7ee974de-20251120";
18019+
exports.version = "19.3.0-native-fb-4cf770d7-20251120";

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMProfiling-profiling.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<389e8c3c5210805cb7ec4a14909fcc12>>
10+
* @generated SignedSource<<03a5c06c35879ff07ea649ce69a50a38>>
1111
*/
1212

1313
/*
@@ -19854,14 +19854,14 @@ ReactDOMHydrationRoot.prototype.unstable_scheduleHydration = function (target) {
1985419854
};
1985519855
var isomorphicReactPackageVersion$jscomp$inline_2370 = React.version;
1985619856
if (
19857-
"19.3.0-native-fb-7ee974de-20251120" !==
19857+
"19.3.0-native-fb-4cf770d7-20251120" !==
1985819858
isomorphicReactPackageVersion$jscomp$inline_2370
1985919859
)
1986019860
throw Error(
1986119861
formatProdErrorMessage(
1986219862
527,
1986319863
isomorphicReactPackageVersion$jscomp$inline_2370,
19864-
"19.3.0-native-fb-7ee974de-20251120"
19864+
"19.3.0-native-fb-4cf770d7-20251120"
1986519865
)
1986619866
);
1986719867
ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
@@ -19883,10 +19883,10 @@ ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
1988319883
};
1988419884
var internals$jscomp$inline_2377 = {
1988519885
bundleType: 0,
19886-
version: "19.3.0-native-fb-7ee974de-20251120",
19886+
version: "19.3.0-native-fb-4cf770d7-20251120",
1988719887
rendererPackageName: "react-dom",
1988819888
currentDispatcherRef: ReactSharedInternals,
19889-
reconcilerVersion: "19.3.0-native-fb-7ee974de-20251120",
19889+
reconcilerVersion: "19.3.0-native-fb-4cf770d7-20251120",
1989019890
getLaneLabelMap: function () {
1989119891
for (
1989219892
var map = new Map(), lane = 1, index$336 = 0;
@@ -20162,7 +20162,7 @@ exports.useFormState = function (action, initialState, permalink) {
2016220162
exports.useFormStatus = function () {
2016320163
return ReactSharedInternals.H.useHostTransitionStatus();
2016420164
};
20165-
exports.version = "19.3.0-native-fb-7ee974de-20251120";
20165+
exports.version = "19.3.0-native-fb-4cf770d7-20251120";
2016620166
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
2016720167
"function" ===
2016820168
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

0 commit comments

Comments
 (0)