Skip to content

Commit 49d9f3f

Browse files
committed
feat(compiler): Implement constant propagation for template literals (#33139)
New take on #29716 ## Summary Template literals consisting entirely of constant values will be inlined to a string literal, effectively replacing the backticks with a double quote. This is done primarily to make the resulting instruction a string literal, so it can be processed further in constant propatation. So this is now correctly simplified to `true`: ```js `` === "" // now true `a${1}` === "a1" // now true ``` If a template string literal can only partially be comptime-evaluated, it is not that useful for dead code elimination or further constant folding steps and thus, is left as-is in that case. Same is true if the literal contains an array, object, symbol or function. ## How did you test this change? See added tests. DiffTrain build for [ac06829](ac06829)
1 parent 8bf45a6 commit 49d9f3f

26 files changed

+181
-89
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.2.0-native-fb-38ef6550-20250508
1+
19.2.0-native-fb-ac068292-20250508

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<<bf136fe6d5dfc8d633a0f613585ff932>>
10+
* @generated SignedSource<<0f0cdbc0ee2edcb4b4b9aa1388adab0b>>
1111
*/
1212

1313
"use strict";
@@ -404,5 +404,5 @@ __DEV__ &&
404404
exports.useFormStatus = function () {
405405
return resolveDispatcher().useHostTransitionStatus();
406406
};
407-
exports.version = "19.2.0-native-fb-38ef6550-20250508";
407+
exports.version = "19.2.0-native-fb-ac068292-20250508";
408408
})();

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<<8662139ea2bf9515a221cba116f4a38a>>
10+
* @generated SignedSource<<d449cb4e74f571609a3d37ce1f13673f>>
1111
*/
1212

1313
"use strict";
@@ -203,4 +203,4 @@ exports.useFormState = function (action, initialState, permalink) {
203203
exports.useFormStatus = function () {
204204
return ReactSharedInternals.H.useHostTransitionStatus();
205205
};
206-
exports.version = "19.2.0-native-fb-38ef6550-20250508";
206+
exports.version = "19.2.0-native-fb-ac068292-20250508";

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<<8662139ea2bf9515a221cba116f4a38a>>
10+
* @generated SignedSource<<d449cb4e74f571609a3d37ce1f13673f>>
1111
*/
1212

1313
"use strict";
@@ -203,4 +203,4 @@ exports.useFormState = function (action, initialState, permalink) {
203203
exports.useFormStatus = function () {
204204
return ReactSharedInternals.H.useHostTransitionStatus();
205205
};
206-
exports.version = "19.2.0-native-fb-38ef6550-20250508";
206+
exports.version = "19.2.0-native-fb-ac068292-20250508";

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<<ad08e1590373068e712038fe4c8862e4>>
10+
* @generated SignedSource<<51e9111c659f59f5093882ab323a900c>>
1111
*/
1212

1313
/*
@@ -26973,11 +26973,11 @@ __DEV__ &&
2697326973
};
2697426974
(function () {
2697526975
var isomorphicReactPackageVersion = React.version;
26976-
if ("19.2.0-native-fb-38ef6550-20250508" !== isomorphicReactPackageVersion)
26976+
if ("19.2.0-native-fb-ac068292-20250508" !== isomorphicReactPackageVersion)
2697726977
throw Error(
2697826978
'Incompatible React versions: The "react" and "react-dom" packages must have the exact same version. Instead got:\n - react: ' +
2697926979
(isomorphicReactPackageVersion +
26980-
"\n - react-dom: 19.2.0-native-fb-38ef6550-20250508\nLearn more: https://react.dev/warnings/version-mismatch")
26980+
"\n - react-dom: 19.2.0-native-fb-ac068292-20250508\nLearn more: https://react.dev/warnings/version-mismatch")
2698126981
);
2698226982
})();
2698326983
("function" === typeof Map &&
@@ -27014,10 +27014,10 @@ __DEV__ &&
2701427014
!(function () {
2701527015
var internals = {
2701627016
bundleType: 1,
27017-
version: "19.2.0-native-fb-38ef6550-20250508",
27017+
version: "19.2.0-native-fb-ac068292-20250508",
2701827018
rendererPackageName: "react-dom",
2701927019
currentDispatcherRef: ReactSharedInternals,
27020-
reconcilerVersion: "19.2.0-native-fb-38ef6550-20250508"
27020+
reconcilerVersion: "19.2.0-native-fb-ac068292-20250508"
2702127021
};
2702227022
internals.overrideHookState = overrideHookState;
2702327023
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
@@ -27161,5 +27161,5 @@ __DEV__ &&
2716127161
listenToAllSupportedEvents(container);
2716227162
return new ReactDOMHydrationRoot(initialChildren);
2716327163
};
27164-
exports.version = "19.2.0-native-fb-38ef6550-20250508";
27164+
exports.version = "19.2.0-native-fb-ac068292-20250508";
2716527165
})();

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<<b9c235ea8a8d61041cc3c38cb8d6a9f6>>
10+
* @generated SignedSource<<fdd3c5a312c8af31f5da81b868897481>>
1111
*/
1212

1313
/*
@@ -17069,14 +17069,14 @@ ReactDOMHydrationRoot.prototype.unstable_scheduleHydration = function (target) {
1706917069
};
1707017070
var isomorphicReactPackageVersion$jscomp$inline_2013 = React.version;
1707117071
if (
17072-
"19.2.0-native-fb-38ef6550-20250508" !==
17072+
"19.2.0-native-fb-ac068292-20250508" !==
1707317073
isomorphicReactPackageVersion$jscomp$inline_2013
1707417074
)
1707517075
throw Error(
1707617076
formatProdErrorMessage(
1707717077
527,
1707817078
isomorphicReactPackageVersion$jscomp$inline_2013,
17079-
"19.2.0-native-fb-38ef6550-20250508"
17079+
"19.2.0-native-fb-ac068292-20250508"
1708017080
)
1708117081
);
1708217082
ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
@@ -17098,10 +17098,10 @@ ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
1709817098
};
1709917099
var internals$jscomp$inline_2532 = {
1710017100
bundleType: 0,
17101-
version: "19.2.0-native-fb-38ef6550-20250508",
17101+
version: "19.2.0-native-fb-ac068292-20250508",
1710217102
rendererPackageName: "react-dom",
1710317103
currentDispatcherRef: ReactSharedInternals,
17104-
reconcilerVersion: "19.2.0-native-fb-38ef6550-20250508"
17104+
reconcilerVersion: "19.2.0-native-fb-ac068292-20250508"
1710517105
};
1710617106
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
1710717107
var hook$jscomp$inline_2533 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
@@ -17205,4 +17205,4 @@ exports.hydrateRoot = function (container, initialChildren, options) {
1720517205
listenToAllSupportedEvents(container);
1720617206
return new ReactDOMHydrationRoot(initialChildren);
1720717207
};
17208-
exports.version = "19.2.0-native-fb-38ef6550-20250508";
17208+
exports.version = "19.2.0-native-fb-ac068292-20250508";

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<<2ab97ce4fd0575f5c88e4f812d1b5a41>>
10+
* @generated SignedSource<<1f9b996163be6768b9380267e581a634>>
1111
*/
1212

1313
/*
@@ -17779,14 +17779,14 @@ ReactDOMHydrationRoot.prototype.unstable_scheduleHydration = function (target) {
1777917779
};
1778017780
var isomorphicReactPackageVersion$jscomp$inline_2116 = React.version;
1778117781
if (
17782-
"19.2.0-native-fb-38ef6550-20250508" !==
17782+
"19.2.0-native-fb-ac068292-20250508" !==
1778317783
isomorphicReactPackageVersion$jscomp$inline_2116
1778417784
)
1778517785
throw Error(
1778617786
formatProdErrorMessage(
1778717787
527,
1778817788
isomorphicReactPackageVersion$jscomp$inline_2116,
17789-
"19.2.0-native-fb-38ef6550-20250508"
17789+
"19.2.0-native-fb-ac068292-20250508"
1779017790
)
1779117791
);
1779217792
ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
@@ -17808,10 +17808,10 @@ ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
1780817808
};
1780917809
var internals$jscomp$inline_2123 = {
1781017810
bundleType: 0,
17811-
version: "19.2.0-native-fb-38ef6550-20250508",
17811+
version: "19.2.0-native-fb-ac068292-20250508",
1781217812
rendererPackageName: "react-dom",
1781317813
currentDispatcherRef: ReactSharedInternals,
17814-
reconcilerVersion: "19.2.0-native-fb-38ef6550-20250508",
17814+
reconcilerVersion: "19.2.0-native-fb-ac068292-20250508",
1781517815
getLaneLabelMap: function () {
1781617816
for (
1781717817
var map = new Map(), lane = 1, index$313 = 0;
@@ -17930,4 +17930,4 @@ exports.hydrateRoot = function (container, initialChildren, options) {
1793017930
listenToAllSupportedEvents(container);
1793117931
return new ReactDOMHydrationRoot(initialChildren);
1793217932
};
17933-
exports.version = "19.2.0-native-fb-38ef6550-20250508";
17933+
exports.version = "19.2.0-native-fb-ac068292-20250508";

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<<7e0dd3ea54c5ac2f8e3fb7e8db73a191>>
10+
* @generated SignedSource<<55b6d4a17ded6af6b3899a62acb7077d>>
1111
*/
1212

1313
/*
@@ -27034,11 +27034,11 @@ __DEV__ &&
2703427034
};
2703527035
(function () {
2703627036
var isomorphicReactPackageVersion = React.version;
27037-
if ("19.2.0-native-fb-38ef6550-20250508" !== isomorphicReactPackageVersion)
27037+
if ("19.2.0-native-fb-ac068292-20250508" !== isomorphicReactPackageVersion)
2703827038
throw Error(
2703927039
'Incompatible React versions: The "react" and "react-dom" packages must have the exact same version. Instead got:\n - react: ' +
2704027040
(isomorphicReactPackageVersion +
27041-
"\n - react-dom: 19.2.0-native-fb-38ef6550-20250508\nLearn more: https://react.dev/warnings/version-mismatch")
27041+
"\n - react-dom: 19.2.0-native-fb-ac068292-20250508\nLearn more: https://react.dev/warnings/version-mismatch")
2704227042
);
2704327043
})();
2704427044
("function" === typeof Map &&
@@ -27075,10 +27075,10 @@ __DEV__ &&
2707527075
!(function () {
2707627076
var internals = {
2707727077
bundleType: 1,
27078-
version: "19.2.0-native-fb-38ef6550-20250508",
27078+
version: "19.2.0-native-fb-ac068292-20250508",
2707927079
rendererPackageName: "react-dom",
2708027080
currentDispatcherRef: ReactSharedInternals,
27081-
reconcilerVersion: "19.2.0-native-fb-38ef6550-20250508"
27081+
reconcilerVersion: "19.2.0-native-fb-ac068292-20250508"
2708227082
};
2708327083
internals.overrideHookState = overrideHookState;
2708427084
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
@@ -27538,7 +27538,7 @@ __DEV__ &&
2753827538
exports.useFormStatus = function () {
2753927539
return resolveDispatcher().useHostTransitionStatus();
2754027540
};
27541-
exports.version = "19.2.0-native-fb-38ef6550-20250508";
27541+
exports.version = "19.2.0-native-fb-ac068292-20250508";
2754227542
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
2754327543
"function" ===
2754427544
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<<acd10792cd4c98f5df3f1f82b37f2ff8>>
10+
* @generated SignedSource<<f6636d3cf7f601e015ac4a1a33e3d9e8>>
1111
*/
1212

1313
/*
@@ -17080,14 +17080,14 @@ ReactDOMHydrationRoot.prototype.unstable_scheduleHydration = function (target) {
1708017080
};
1708117081
var isomorphicReactPackageVersion$jscomp$inline_2014 = React.version;
1708217082
if (
17083-
"19.2.0-native-fb-38ef6550-20250508" !==
17083+
"19.2.0-native-fb-ac068292-20250508" !==
1708417084
isomorphicReactPackageVersion$jscomp$inline_2014
1708517085
)
1708617086
throw Error(
1708717087
formatProdErrorMessage(
1708817088
527,
1708917089
isomorphicReactPackageVersion$jscomp$inline_2014,
17090-
"19.2.0-native-fb-38ef6550-20250508"
17090+
"19.2.0-native-fb-ac068292-20250508"
1709117091
)
1709217092
);
1709317093
ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
@@ -17109,10 +17109,10 @@ ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
1710917109
};
1711017110
var internals$jscomp$inline_2535 = {
1711117111
bundleType: 0,
17112-
version: "19.2.0-native-fb-38ef6550-20250508",
17112+
version: "19.2.0-native-fb-ac068292-20250508",
1711317113
rendererPackageName: "react-dom",
1711417114
currentDispatcherRef: ReactSharedInternals,
17115-
reconcilerVersion: "19.2.0-native-fb-38ef6550-20250508"
17115+
reconcilerVersion: "19.2.0-native-fb-ac068292-20250508"
1711617116
};
1711717117
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
1711817118
var hook$jscomp$inline_2536 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
@@ -17370,4 +17370,4 @@ exports.useFormState = function (action, initialState, permalink) {
1737017370
exports.useFormStatus = function () {
1737117371
return ReactSharedInternals.H.useHostTransitionStatus();
1737217372
};
17373-
exports.version = "19.2.0-native-fb-38ef6550-20250508";
17373+
exports.version = "19.2.0-native-fb-ac068292-20250508";

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<<7ce7b954fd069055f6881dff74e49e07>>
10+
* @generated SignedSource<<3be605dcb9ae3379544766421df9b7e5>>
1111
*/
1212

1313
/*
@@ -17794,14 +17794,14 @@ ReactDOMHydrationRoot.prototype.unstable_scheduleHydration = function (target) {
1779417794
};
1779517795
var isomorphicReactPackageVersion$jscomp$inline_2117 = React.version;
1779617796
if (
17797-
"19.2.0-native-fb-38ef6550-20250508" !==
17797+
"19.2.0-native-fb-ac068292-20250508" !==
1779817798
isomorphicReactPackageVersion$jscomp$inline_2117
1779917799
)
1780017800
throw Error(
1780117801
formatProdErrorMessage(
1780217802
527,
1780317803
isomorphicReactPackageVersion$jscomp$inline_2117,
17804-
"19.2.0-native-fb-38ef6550-20250508"
17804+
"19.2.0-native-fb-ac068292-20250508"
1780517805
)
1780617806
);
1780717807
ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
@@ -17823,10 +17823,10 @@ ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
1782317823
};
1782417824
var internals$jscomp$inline_2124 = {
1782517825
bundleType: 0,
17826-
version: "19.2.0-native-fb-38ef6550-20250508",
17826+
version: "19.2.0-native-fb-ac068292-20250508",
1782717827
rendererPackageName: "react-dom",
1782817828
currentDispatcherRef: ReactSharedInternals,
17829-
reconcilerVersion: "19.2.0-native-fb-38ef6550-20250508",
17829+
reconcilerVersion: "19.2.0-native-fb-ac068292-20250508",
1783017830
getLaneLabelMap: function () {
1783117831
for (
1783217832
var map = new Map(), lane = 1, index$313 = 0;
@@ -18099,7 +18099,7 @@ exports.useFormState = function (action, initialState, permalink) {
1809918099
exports.useFormStatus = function () {
1810018100
return ReactSharedInternals.H.useHostTransitionStatus();
1810118101
};
18102-
exports.version = "19.2.0-native-fb-38ef6550-20250508";
18102+
exports.version = "19.2.0-native-fb-ac068292-20250508";
1810318103
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
1810418104
"function" ===
1810518105
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

0 commit comments

Comments
 (0)