Skip to content

Commit d1f9770

Browse files
committed
refactor: use ESM exports in ReactNativeViewConfigRegistry (#27508)
## Summary When transpiling `react-native` with `swc` this file caused some trouble as it mixes ESM and CJS import/export syntax. This PR addresses this by converting CJS exports to ESM exports. As `ReactNativeViewConfigRegistry` is synced from `react` to `react-native` repository, it's required to make the change here. I've also aligned the mock of `ReactNativeViewConfigRegistry` to reflect current implementation. Related PR in `react-native`: facebook/react-native#40787 DiffTrain build for commit ea8a861.
1 parent a892e8a commit d1f9770

File tree

8 files changed

+16
-19
lines changed

8 files changed

+16
-19
lines changed

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-dev.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24770,7 +24770,7 @@ function createFiberRoot(
2477024770
return root;
2477124771
}
2477224772

24773-
var ReactVersion = "18.3.0-canary-e61a60fac-20231011";
24773+
var ReactVersion = "18.3.0-canary-ea8a8619c-20231012";
2477424774

2477524775
// Might add PROFILE later.
2477624776

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-prod.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8968,7 +8968,7 @@ var devToolsConfig$jscomp$inline_1008 = {
89688968
throw Error("TestRenderer does not support findFiberByHostInstance()");
89698969
},
89708970
bundleType: 0,
8971-
version: "18.3.0-canary-e61a60fac-20231011",
8971+
version: "18.3.0-canary-ea8a8619c-20231012",
89728972
rendererPackageName: "react-test-renderer"
89738973
};
89748974
var internals$jscomp$inline_1201 = {
@@ -8999,7 +8999,7 @@ var internals$jscomp$inline_1201 = {
89998999
scheduleRoot: null,
90009000
setRefreshHandler: null,
90019001
getCurrentFiber: null,
9002-
reconcilerVersion: "18.3.0-canary-e61a60fac-20231011"
9002+
reconcilerVersion: "18.3.0-canary-ea8a8619c-20231012"
90039003
};
90049004
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
90059005
var hook$jscomp$inline_1202 = __REACT_DEVTOOLS_GLOBAL_HOOK__;

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-profiling.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9394,7 +9394,7 @@ var devToolsConfig$jscomp$inline_1050 = {
93949394
throw Error("TestRenderer does not support findFiberByHostInstance()");
93959395
},
93969396
bundleType: 0,
9397-
version: "18.3.0-canary-e61a60fac-20231011",
9397+
version: "18.3.0-canary-ea8a8619c-20231012",
93989398
rendererPackageName: "react-test-renderer"
93999399
};
94009400
var internals$jscomp$inline_1242 = {
@@ -9425,7 +9425,7 @@ var internals$jscomp$inline_1242 = {
94259425
scheduleRoot: null,
94269426
setRefreshHandler: null,
94279427
getCurrentFiber: null,
9428-
reconcilerVersion: "18.3.0-canary-e61a60fac-20231011"
9428+
reconcilerVersion: "18.3.0-canary-ea8a8619c-20231012"
94299429
};
94309430
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
94319431
var hook$jscomp$inline_1243 = __REACT_DEVTOOLS_GLOBAL_HOOK__;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ if (
2727
}
2828
"use strict";
2929

30-
var ReactVersion = "18.3.0-canary-e61a60fac-20231011";
30+
var ReactVersion = "18.3.0-canary-ea8a8619c-20231012";
3131

3232
// ATTENTION
3333
// When adding new symbols to this file,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,4 +580,4 @@ exports.useSyncExternalStore = function (
580580
exports.useTransition = function () {
581581
return ReactCurrentDispatcher.current.useTransition();
582582
};
583-
exports.version = "18.3.0-canary-e61a60fac-20231011";
583+
exports.version = "18.3.0-canary-ea8a8619c-20231012";

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@ exports.useSyncExternalStore = function (
583583
exports.useTransition = function () {
584584
return ReactCurrentDispatcher.current.useTransition();
585585
};
586-
exports.version = "18.3.0-canary-e61a60fac-20231011";
586+
exports.version = "18.3.0-canary-ea8a8619c-20231012";
587587

588588
/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
589589
if (
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
e61a60fac02d205ad928bff6de2449f00646a92c
1+
ea8a8619ce51a0f8f0a78f87485e4e2a6f9d8c27

compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/shims/ReactNativeViewConfigRegistry.js

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noformat
88
* @flow strict-local
99
* @nolint
10-
* @generated SignedSource<<1b39316520f5af25f0a141d7d78b0809>>
10+
* @generated SignedSource<<3cf9b746913da1666cb5bce0ae12d978>>
1111
*/
1212

1313
'use strict';
@@ -16,7 +16,7 @@ import {type ViewConfig} from './ReactNativeTypes';
1616
import invariant from 'invariant';
1717

1818
// Event configs
19-
const customBubblingEventTypes: {
19+
export const customBubblingEventTypes: {
2020
[eventName: string]: $ReadOnly<{
2121
phasedRegistrationNames: $ReadOnly<{
2222
captured: string,
@@ -26,16 +26,13 @@ const customBubblingEventTypes: {
2626
}>,
2727
...
2828
} = {};
29-
const customDirectEventTypes: {
29+
export const customDirectEventTypes: {
3030
[eventName: string]: $ReadOnly<{
3131
registrationName: string,
3232
}>,
3333
...
3434
} = {};
3535

36-
exports.customBubblingEventTypes = customBubblingEventTypes;
37-
exports.customDirectEventTypes = customDirectEventTypes;
38-
3936
const viewConfigCallbacks = new Map<string, ?() => ViewConfig>();
4037
const viewConfigs = new Map<string, ViewConfig>();
4138

@@ -77,7 +74,7 @@ function processEventTypes(viewConfig: ViewConfig): void {
7774
* A callback is provided to load the view config from UIManager.
7875
* The callback is deferred until the view is actually rendered.
7976
*/
80-
exports.register = function (name: string, callback: () => ViewConfig): string {
77+
export function register(name: string, callback: () => ViewConfig): string {
8178
invariant(
8279
!viewConfigCallbacks.has(name),
8380
'Tried to register two views with the same name %s',
@@ -91,14 +88,14 @@ exports.register = function (name: string, callback: () => ViewConfig): string {
9188
);
9289
viewConfigCallbacks.set(name, callback);
9390
return name;
94-
};
91+
}
9592

9693
/**
9794
* Retrieves a config for the specified view.
9895
* If this is the first time the view has been used,
9996
* This configuration will be lazy-loaded from UIManager.
10097
*/
101-
exports.get = function (name: string): ViewConfig {
98+
export function get(name: string): ViewConfig {
10299
let viewConfig;
103100
if (!viewConfigs.has(name)) {
104101
const callback = viewConfigCallbacks.get(name);
@@ -126,4 +123,4 @@ exports.get = function (name: string): ViewConfig {
126123
}
127124
invariant(viewConfig, 'View config not found for name %s', name);
128125
return viewConfig;
129-
};
126+
}

0 commit comments

Comments
 (0)