diff --git a/packages/react-native/Libraries/BatchedBridge/MessageQueue.js b/packages/react-native/Libraries/BatchedBridge/MessageQueue.js index e22485f2a5e..719d33ad8ae 100644 --- a/packages/react-native/Libraries/BatchedBridge/MessageQueue.js +++ b/packages/react-native/Libraries/BatchedBridge/MessageQueue.js @@ -14,7 +14,7 @@ const Systrace = require('../Performance/Systrace'); const deepFreezeAndThrowOnMutationInDev = require('../Utilities/deepFreezeAndThrowOnMutationInDev'); const stringifySafe = require('../Utilities/stringifySafe').default; const warnOnce = require('../Utilities/warnOnce'); -const ErrorUtils = require('../vendor/core/ErrorUtils'); +const ErrorUtils = require('../vendor/core/ErrorUtils').default; const invariant = require('invariant'); export type SpyData = { diff --git a/packages/react-native/Libraries/BugReporting/BugReporting.js b/packages/react-native/Libraries/BugReporting/BugReporting.js index 2ee616af829..a11ad808484 100644 --- a/packages/react-native/Libraries/BugReporting/BugReporting.js +++ b/packages/react-native/Libraries/BugReporting/BugReporting.js @@ -23,7 +23,7 @@ type DebugData = { function defaultExtras() { BugReporting.addFileSource('react_hierarchy.txt', () => - require('./dumpReactTree')(), + require('./dumpReactTree').default(), ); } @@ -137,4 +137,4 @@ class BugReporting { } } -module.exports = BugReporting; +export default BugReporting; diff --git a/packages/react-native/Libraries/BugReporting/dumpReactTree.js b/packages/react-native/Libraries/BugReporting/dumpReactTree.js index 6673657d42a..e5a2b770d3d 100644 --- a/packages/react-native/Libraries/BugReporting/dumpReactTree.js +++ b/packages/react-native/Libraries/BugReporting/dumpReactTree.js @@ -11,7 +11,7 @@ 'use strict'; /* -const getReactData = require('getReactData'); +const getReactData = require('getReactData').default; const INDENTATION_SIZE = 2; const MAX_DEPTH = 2; @@ -148,4 +148,4 @@ function indent(size: number) { } */ -module.exports = dumpReactTree; +export default dumpReactTree; diff --git a/packages/react-native/Libraries/BugReporting/getReactData.js b/packages/react-native/Libraries/BugReporting/getReactData.js index cc988ced109..ea0da5e15ef 100644 --- a/packages/react-native/Libraries/BugReporting/getReactData.js +++ b/packages/react-native/Libraries/BugReporting/getReactData.js @@ -184,4 +184,4 @@ function copyWithSet( return copyWithSetImpl(obj, path, 0, value); } -module.exports = getData; +export default getData; diff --git a/packages/react-native/Libraries/Core/setUpErrorHandling.js b/packages/react-native/Libraries/Core/setUpErrorHandling.js index b2518260edf..aa2c368d7dc 100644 --- a/packages/react-native/Libraries/Core/setUpErrorHandling.js +++ b/packages/react-native/Libraries/Core/setUpErrorHandling.js @@ -34,7 +34,7 @@ if (global.RN$useAlwaysAvailableJSErrorHandling !== true) { } }; - const ErrorUtils = require('../vendor/core/ErrorUtils'); + const ErrorUtils = require('../vendor/core/ErrorUtils').default; ErrorUtils.setGlobalHandler(handleError); } } diff --git a/packages/react-native/Libraries/Vibration/Vibration.js b/packages/react-native/Libraries/Vibration/Vibration.js index db124c63235..cee97dc1bd5 100644 --- a/packages/react-native/Libraries/Vibration/Vibration.js +++ b/packages/react-native/Libraries/Vibration/Vibration.js @@ -110,4 +110,4 @@ const Vibration = { }, }; -module.exports = Vibration; +export default Vibration; diff --git a/packages/react-native/Libraries/YellowBox/YellowBoxDeprecated.js b/packages/react-native/Libraries/YellowBox/YellowBoxDeprecated.js index c6a0f0d964c..dfa5757ef0b 100644 --- a/packages/react-native/Libraries/YellowBox/YellowBoxDeprecated.js +++ b/packages/react-native/Libraries/YellowBox/YellowBoxDeprecated.js @@ -68,7 +68,7 @@ if (__DEV__) { } // $FlowFixMe[method-unbinding] -module.exports = (YellowBox: Class> & { +export default (YellowBox: Class> & { ignoreWarnings($ReadOnlyArray): void, install(): void, uninstall(): void, diff --git a/packages/react-native/Libraries/YellowBox/__tests__/YellowBoxDeprecated-test.js b/packages/react-native/Libraries/YellowBox/__tests__/YellowBoxDeprecated-test.js index a97e46ea67b..5e972213afe 100644 --- a/packages/react-native/Libraries/YellowBox/__tests__/YellowBoxDeprecated-test.js +++ b/packages/react-native/Libraries/YellowBox/__tests__/YellowBoxDeprecated-test.js @@ -12,7 +12,7 @@ 'use strict'; const LogBox = require('../../LogBox/LogBox').default; -const YellowBox = require('../YellowBoxDeprecated'); +const YellowBox = require('../YellowBoxDeprecated').default; describe('YellowBox', () => { beforeEach(() => { diff --git a/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap b/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap index 78fc677b1cb..597b32390b7 100644 --- a/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap +++ b/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap @@ -1540,7 +1540,7 @@ declare class BugReporting { ): { remove: () => void, ... }; static collectExtraData(): DebugData; } -declare module.exports: BugReporting; +declare export default typeof BugReporting; " `; @@ -1552,13 +1552,13 @@ declare export default typeof NativeBugReporting; exports[`public API should not change unintentionally Libraries/BugReporting/dumpReactTree.js 1`] = ` "declare function dumpReactTree(): string; -declare module.exports: dumpReactTree; +declare export default typeof dumpReactTree; " `; exports[`public API should not change unintentionally Libraries/BugReporting/getReactData.js 1`] = ` "declare function getData(element: Object): Object; -declare module.exports: getData; +declare export default typeof getData; " `; @@ -9406,7 +9406,7 @@ exports[`public API should not change unintentionally Libraries/Vibration/Vibrat vibrate: (pattern: number | Array, repeat: boolean) => void, cancel: () => void, }; -declare module.exports: Vibration; +declare export default typeof Vibration; " `; @@ -9510,7 +9510,7 @@ declare module.exports: WebSocketInterceptor; exports[`public API should not change unintentionally Libraries/YellowBox/YellowBoxDeprecated.js 1`] = ` "type Props = $ReadOnly<{}>; -declare module.exports: Class> & { +declare export default Class> & { ignoreWarnings($ReadOnlyArray): void, install(): void, uninstall(): void, @@ -9526,7 +9526,7 @@ declare export default typeof rejectionTrackingOptions; `; exports[`public API should not change unintentionally Libraries/vendor/core/ErrorUtils.js 1`] = ` -"declare module.exports: ErrorUtilsT; +"declare export default ErrorUtilsT; " `; diff --git a/packages/react-native/Libraries/vendor/core/ErrorUtils.js b/packages/react-native/Libraries/vendor/core/ErrorUtils.js index 37b0da17cd1..3d331a5166b 100644 --- a/packages/react-native/Libraries/vendor/core/ErrorUtils.js +++ b/packages/react-native/Libraries/vendor/core/ErrorUtils.js @@ -22,4 +22,4 @@ import type {ErrorUtilsT} from '@react-native/js-polyfills/error-guard'; * that use it aren't just using a global variable, so simply export the global * variable here. ErrorUtils is originally defined in a file named error-guard.js. */ -module.exports = (global.ErrorUtils: ErrorUtilsT); +export default (global.ErrorUtils: ErrorUtilsT); diff --git a/packages/react-native/index.js b/packages/react-native/index.js index dd02a72040c..3086f22a316 100644 --- a/packages/react-native/index.js +++ b/packages/react-native/index.js @@ -350,10 +350,10 @@ module.exports = { return require('./Libraries/UTFSequence').default; }, get Vibration(): Vibration { - return require('./Libraries/Vibration/Vibration'); + return require('./Libraries/Vibration/Vibration').default; }, get YellowBox(): YellowBox { - return require('./Libraries/YellowBox/YellowBoxDeprecated'); + return require('./Libraries/YellowBox/YellowBoxDeprecated').default; }, // Plugins diff --git a/packages/react-native/jest/setup.js b/packages/react-native/jest/setup.js index d4574316419..94a9f1ab4d2 100644 --- a/packages/react-native/jest/setup.js +++ b/packages/react-native/jest/setup.js @@ -430,8 +430,11 @@ jest return jest.requireActual('./mockNativeComponent'); }) .mock('../Libraries/Vibration/Vibration', () => ({ - vibrate: jest.fn(), - cancel: jest.fn(), + __esModule: true, + default: { + vibrate: jest.fn(), + cancel: jest.fn(), + }, })) .mock('../Libraries/Components/View/ViewNativeComponent', () => { const React = require('react');