Skip to content

Commit

Permalink
[rcr] Re-export useMemoCache in top level React namespace (#31139)
Browse files Browse the repository at this point in the history
In order to support using the compiler on versions of React prior to 19,
we need the ability to statically import `c` (aka useMemoCache) or
fallback to a polyfill supplied by `react-compiler-runtime` (note: this
is a separate npm package, not to be confused with
`react/compiler-runtime`, which is currently a part of react).

To do this we first need to re-export `useMemoCache` under the top level
React namespace again, which is additive and thus non-breaking. Doing so
allows `react-compiler-runtime` to statically either re-export
`React.__COMPILER_RUNTIME.c` or supply a polyfill, without the need for
a dynamic import which is finicky to support due to returning a promise.

In later PRs I will remove `react/compiler-runtime` and update the
compiler to emit imports to `react-compiler-runtime` instead.

DiffTrain build for [b78a7f2](b78a7f2)
  • Loading branch information
poteto committed Oct 7, 2024
1 parent 6acd66e commit b3b172a
Show file tree
Hide file tree
Showing 23 changed files with 93 additions and 87 deletions.
2 changes: 1 addition & 1 deletion compiled-rn/VERSION_NATIVE_FB
Original file line number Diff line number Diff line change
@@ -1 +1 @@
19.0.0-native-fb-459fd418-20241001
19.0.0-native-fb-b78a7f2f-20241007
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<333789674f3a865b32eba498659ac910>>
* @generated SignedSource<<d5faa91f4a5f8a6940d890f72a303b54>>
*/

"use strict";
Expand Down Expand Up @@ -420,5 +420,5 @@ __DEV__ &&
exports.useFormStatus = function () {
return resolveDispatcher().useHostTransitionStatus();
};
exports.version = "19.0.0-native-fb-459fd418-20241001";
exports.version = "19.0.0-native-fb-b78a7f2f-20241007";
})();
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<079922b0a92a10633e0f40e43b54b735>>
* @generated SignedSource<<19418ee514eca4bcaf1ba0d649a720b4>>
*/

"use strict";
Expand Down Expand Up @@ -203,4 +203,4 @@ exports.useFormState = function (action, initialState, permalink) {
exports.useFormStatus = function () {
return ReactSharedInternals.H.useHostTransitionStatus();
};
exports.version = "19.0.0-native-fb-459fd418-20241001";
exports.version = "19.0.0-native-fb-b78a7f2f-20241007";
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<079922b0a92a10633e0f40e43b54b735>>
* @generated SignedSource<<19418ee514eca4bcaf1ba0d649a720b4>>
*/

"use strict";
Expand Down Expand Up @@ -203,4 +203,4 @@ exports.useFormState = function (action, initialState, permalink) {
exports.useFormStatus = function () {
return ReactSharedInternals.H.useHostTransitionStatus();
};
exports.version = "19.0.0-native-fb-459fd418-20241001";
exports.version = "19.0.0-native-fb-b78a7f2f-20241007";
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<81900bfb513fc0c38794b9e3c210915a>>
* @generated SignedSource<<50538a711c0ffae7621f4907d19f5002>>
*/

/*
Expand Down Expand Up @@ -25304,11 +25304,11 @@ __DEV__ &&
};
(function () {
var isomorphicReactPackageVersion = React.version;
if ("19.0.0-native-fb-459fd418-20241001" !== isomorphicReactPackageVersion)
if ("19.0.0-native-fb-b78a7f2f-20241007" !== isomorphicReactPackageVersion)
throw Error(
'Incompatible React versions: The "react" and "react-dom" packages must have the exact same version. Instead got:\n - react: ' +
(isomorphicReactPackageVersion +
"\n - react-dom: 19.0.0-native-fb-459fd418-20241001\nLearn more: https://react.dev/warnings/version-mismatch")
"\n - react-dom: 19.0.0-native-fb-b78a7f2f-20241007\nLearn more: https://react.dev/warnings/version-mismatch")
);
})();
("function" === typeof Map &&
Expand Down Expand Up @@ -25345,11 +25345,11 @@ __DEV__ &&
!(function () {
var internals = {
bundleType: 1,
version: "19.0.0-native-fb-459fd418-20241001",
version: "19.0.0-native-fb-b78a7f2f-20241007",
rendererPackageName: "react-dom",
currentDispatcherRef: ReactSharedInternals,
findFiberByHostInstance: getClosestInstanceFromNode,
reconcilerVersion: "19.0.0-native-fb-459fd418-20241001"
reconcilerVersion: "19.0.0-native-fb-b78a7f2f-20241007"
};
internals.overrideHookState = overrideHookState;
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
Expand Down Expand Up @@ -25493,5 +25493,5 @@ __DEV__ &&
listenToAllSupportedEvents(container);
return new ReactDOMHydrationRoot(initialChildren);
};
exports.version = "19.0.0-native-fb-459fd418-20241001";
exports.version = "19.0.0-native-fb-b78a7f2f-20241007";
})();
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<bb77136cedd422081ff7603adc64a4d5>>
* @generated SignedSource<<66c9a1a1221b0f25c3fc6b802381a71f>>
*/

/*
Expand Down Expand Up @@ -15598,14 +15598,14 @@ ReactDOMHydrationRoot.prototype.unstable_scheduleHydration = function (target) {
};
var isomorphicReactPackageVersion$jscomp$inline_1691 = React.version;
if (
"19.0.0-native-fb-459fd418-20241001" !==
"19.0.0-native-fb-b78a7f2f-20241007" !==
isomorphicReactPackageVersion$jscomp$inline_1691
)
throw Error(
formatProdErrorMessage(
527,
isomorphicReactPackageVersion$jscomp$inline_1691,
"19.0.0-native-fb-459fd418-20241001"
"19.0.0-native-fb-b78a7f2f-20241007"
)
);
ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
Expand All @@ -15627,11 +15627,11 @@ ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
};
var internals$jscomp$inline_2144 = {
bundleType: 0,
version: "19.0.0-native-fb-459fd418-20241001",
version: "19.0.0-native-fb-b78a7f2f-20241007",
rendererPackageName: "react-dom",
currentDispatcherRef: ReactSharedInternals,
findFiberByHostInstance: getClosestInstanceFromNode,
reconcilerVersion: "19.0.0-native-fb-459fd418-20241001"
reconcilerVersion: "19.0.0-native-fb-b78a7f2f-20241007"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_2145 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
Expand Down Expand Up @@ -15735,4 +15735,4 @@ exports.hydrateRoot = function (container, initialChildren, options) {
listenToAllSupportedEvents(container);
return new ReactDOMHydrationRoot(initialChildren);
};
exports.version = "19.0.0-native-fb-459fd418-20241001";
exports.version = "19.0.0-native-fb-b78a7f2f-20241007";
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<54e57ea222e9bfd9dbf750496a69abc8>>
* @generated SignedSource<<0a35ca8dced5c33f584e6582ef1df166>>
*/

/*
Expand Down Expand Up @@ -16255,14 +16255,14 @@ ReactDOMHydrationRoot.prototype.unstable_scheduleHydration = function (target) {
};
var isomorphicReactPackageVersion$jscomp$inline_1781 = React.version;
if (
"19.0.0-native-fb-459fd418-20241001" !==
"19.0.0-native-fb-b78a7f2f-20241007" !==
isomorphicReactPackageVersion$jscomp$inline_1781
)
throw Error(
formatProdErrorMessage(
527,
isomorphicReactPackageVersion$jscomp$inline_1781,
"19.0.0-native-fb-459fd418-20241001"
"19.0.0-native-fb-b78a7f2f-20241007"
)
);
ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
Expand All @@ -16284,11 +16284,11 @@ ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
};
var internals$jscomp$inline_1788 = {
bundleType: 0,
version: "19.0.0-native-fb-459fd418-20241001",
version: "19.0.0-native-fb-b78a7f2f-20241007",
rendererPackageName: "react-dom",
currentDispatcherRef: ReactSharedInternals,
findFiberByHostInstance: getClosestInstanceFromNode,
reconcilerVersion: "19.0.0-native-fb-459fd418-20241001",
reconcilerVersion: "19.0.0-native-fb-b78a7f2f-20241007",
getLaneLabelMap: function () {
for (
var map = new Map(), lane = 1, index$286 = 0;
Expand Down Expand Up @@ -16407,4 +16407,4 @@ exports.hydrateRoot = function (container, initialChildren, options) {
listenToAllSupportedEvents(container);
return new ReactDOMHydrationRoot(initialChildren);
};
exports.version = "19.0.0-native-fb-459fd418-20241001";
exports.version = "19.0.0-native-fb-b78a7f2f-20241007";
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<ee0f9fb7d05a1c29290cae2dd15d3f4e>>
* @generated SignedSource<<8c1b7dae604278006c2ff6473ace83e0>>
*/

/*
Expand Down Expand Up @@ -25365,11 +25365,11 @@ __DEV__ &&
};
(function () {
var isomorphicReactPackageVersion = React.version;
if ("19.0.0-native-fb-459fd418-20241001" !== isomorphicReactPackageVersion)
if ("19.0.0-native-fb-b78a7f2f-20241007" !== isomorphicReactPackageVersion)
throw Error(
'Incompatible React versions: The "react" and "react-dom" packages must have the exact same version. Instead got:\n - react: ' +
(isomorphicReactPackageVersion +
"\n - react-dom: 19.0.0-native-fb-459fd418-20241001\nLearn more: https://react.dev/warnings/version-mismatch")
"\n - react-dom: 19.0.0-native-fb-b78a7f2f-20241007\nLearn more: https://react.dev/warnings/version-mismatch")
);
})();
("function" === typeof Map &&
Expand Down Expand Up @@ -25406,11 +25406,11 @@ __DEV__ &&
!(function () {
var internals = {
bundleType: 1,
version: "19.0.0-native-fb-459fd418-20241001",
version: "19.0.0-native-fb-b78a7f2f-20241007",
rendererPackageName: "react-dom",
currentDispatcherRef: ReactSharedInternals,
findFiberByHostInstance: getClosestInstanceFromNode,
reconcilerVersion: "19.0.0-native-fb-459fd418-20241001"
reconcilerVersion: "19.0.0-native-fb-b78a7f2f-20241007"
};
internals.overrideHookState = overrideHookState;
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
Expand Down Expand Up @@ -25870,7 +25870,7 @@ __DEV__ &&
exports.useFormStatus = function () {
return resolveDispatcher().useHostTransitionStatus();
};
exports.version = "19.0.0-native-fb-459fd418-20241001";
exports.version = "19.0.0-native-fb-b78a7f2f-20241007";
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
"function" ===
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<de7905821e9bd8b0b0114678b6e7f3bf>>
* @generated SignedSource<<32a7570edfe1e2a0b4a6c63c9684eea8>>
*/

/*
Expand Down Expand Up @@ -15609,14 +15609,14 @@ ReactDOMHydrationRoot.prototype.unstable_scheduleHydration = function (target) {
};
var isomorphicReactPackageVersion$jscomp$inline_1692 = React.version;
if (
"19.0.0-native-fb-459fd418-20241001" !==
"19.0.0-native-fb-b78a7f2f-20241007" !==
isomorphicReactPackageVersion$jscomp$inline_1692
)
throw Error(
formatProdErrorMessage(
527,
isomorphicReactPackageVersion$jscomp$inline_1692,
"19.0.0-native-fb-459fd418-20241001"
"19.0.0-native-fb-b78a7f2f-20241007"
)
);
ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
Expand All @@ -15638,11 +15638,11 @@ ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
};
var internals$jscomp$inline_2147 = {
bundleType: 0,
version: "19.0.0-native-fb-459fd418-20241001",
version: "19.0.0-native-fb-b78a7f2f-20241007",
rendererPackageName: "react-dom",
currentDispatcherRef: ReactSharedInternals,
findFiberByHostInstance: getClosestInstanceFromNode,
reconcilerVersion: "19.0.0-native-fb-459fd418-20241001"
reconcilerVersion: "19.0.0-native-fb-b78a7f2f-20241007"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_2148 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
Expand Down Expand Up @@ -15900,4 +15900,4 @@ exports.useFormState = function (action, initialState, permalink) {
exports.useFormStatus = function () {
return ReactSharedInternals.H.useHostTransitionStatus();
};
exports.version = "19.0.0-native-fb-459fd418-20241001";
exports.version = "19.0.0-native-fb-b78a7f2f-20241007";
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<a8958828a6f1c9be677992cbbc2cdd34>>
* @generated SignedSource<<15cc6efda2582697662984eedd53fbd5>>
*/

/*
Expand Down Expand Up @@ -16270,14 +16270,14 @@ ReactDOMHydrationRoot.prototype.unstable_scheduleHydration = function (target) {
};
var isomorphicReactPackageVersion$jscomp$inline_1782 = React.version;
if (
"19.0.0-native-fb-459fd418-20241001" !==
"19.0.0-native-fb-b78a7f2f-20241007" !==
isomorphicReactPackageVersion$jscomp$inline_1782
)
throw Error(
formatProdErrorMessage(
527,
isomorphicReactPackageVersion$jscomp$inline_1782,
"19.0.0-native-fb-459fd418-20241001"
"19.0.0-native-fb-b78a7f2f-20241007"
)
);
ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
Expand All @@ -16299,11 +16299,11 @@ ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
};
var internals$jscomp$inline_1789 = {
bundleType: 0,
version: "19.0.0-native-fb-459fd418-20241001",
version: "19.0.0-native-fb-b78a7f2f-20241007",
rendererPackageName: "react-dom",
currentDispatcherRef: ReactSharedInternals,
findFiberByHostInstance: getClosestInstanceFromNode,
reconcilerVersion: "19.0.0-native-fb-459fd418-20241001",
reconcilerVersion: "19.0.0-native-fb-b78a7f2f-20241007",
getLaneLabelMap: function () {
for (
var map = new Map(), lane = 1, index$286 = 0;
Expand Down Expand Up @@ -16576,7 +16576,7 @@ exports.useFormState = function (action, initialState, permalink) {
exports.useFormStatus = function () {
return ReactSharedInternals.H.useHostTransitionStatus();
};
exports.version = "19.0.0-native-fb-459fd418-20241001";
exports.version = "19.0.0-native-fb-b78a7f2f-20241007";
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
"function" ===
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<1d53c7bc3d0ae903c61fa8595d08393e>>
* @generated SignedSource<<57eaa37e0992b9ff5709317b55eae2af>>
*/

"use strict";
Expand Down Expand Up @@ -15136,11 +15136,11 @@ __DEV__ &&
(function () {
var internals = {
bundleType: 1,
version: "19.0.0-native-fb-459fd418-20241001",
version: "19.0.0-native-fb-b78a7f2f-20241007",
rendererPackageName: "react-test-renderer",
currentDispatcherRef: ReactSharedInternals,
findFiberByHostInstance: getInstanceFromNode,
reconcilerVersion: "19.0.0-native-fb-459fd418-20241001"
reconcilerVersion: "19.0.0-native-fb-b78a7f2f-20241007"
};
internals.overrideHookState = overrideHookState;
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
Expand Down Expand Up @@ -15285,5 +15285,5 @@ __DEV__ &&
flushSyncWorkAcrossRoots_impl(0, !0));
}
};
exports.version = "19.0.0-native-fb-459fd418-20241001";
exports.version = "19.0.0-native-fb-b78a7f2f-20241007";
})();
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<61ae7a14b1c2fe4d5a62116dd0057516>>
* @generated SignedSource<<f6849f0e258dac90e87357636acbd312>>
*/

"use strict";
Expand Down Expand Up @@ -9520,14 +9520,14 @@ function wrapFiber(fiber) {
}
var internals$jscomp$inline_1346 = {
bundleType: 0,
version: "19.0.0-native-fb-459fd418-20241001",
version: "19.0.0-native-fb-b78a7f2f-20241007",
rendererPackageName: "react-test-renderer",
currentDispatcherRef: ReactSharedInternals,
findFiberByHostInstance: function (mockNode) {
mockNode = nodeToInstanceMap.get(mockNode);
return void 0 !== mockNode ? mockNode.internalInstanceHandle : null;
},
reconcilerVersion: "19.0.0-native-fb-459fd418-20241001"
reconcilerVersion: "19.0.0-native-fb-b78a7f2f-20241007"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_1347 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
Expand Down Expand Up @@ -9663,4 +9663,4 @@ exports.unstable_batchedUpdates = function (fn, a) {
flushSyncWorkAcrossRoots_impl(0, !0));
}
};
exports.version = "19.0.0-native-fb-459fd418-20241001";
exports.version = "19.0.0-native-fb-b78a7f2f-20241007";
Loading

0 comments on commit b3b172a

Please sign in to comment.