Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
'use strict';

const Systrace = require('../Performance/Systrace');
const deepFreezeAndThrowOnMutationInDev = require('../Utilities/deepFreezeAndThrowOnMutationInDev');
const deepFreezeAndThrowOnMutationInDev =
require('../Utilities/deepFreezeAndThrowOnMutationInDev').default;
const stringifySafe = require('../Utilities/stringifySafe').default;
const warnOnce = require('../Utilities/warnOnce');
const ErrorUtils = require('../vendor/core/ErrorUtils').default;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,8 @@ if (global.nativeModuleProxy) {
'__fbBatchedBridgeConfig is not set, cannot invoke native modules',
);

const defineLazyObjectProperty = require('../Utilities/defineLazyObjectProperty');
const defineLazyObjectProperty =
require('../Utilities/defineLazyObjectProperty').default;
(bridgeConfig.remoteModuleConfig || []).forEach(
(config: ModuleConfig, moduleID: number) => {
// Initially this config will only contain the module name when running in JSC. The actual
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ import NativeUIManager from './NativeUIManager';
import nullthrows from 'nullthrows';

const NativeModules = require('../BatchedBridge/NativeModules').default;
const defineLazyObjectProperty = require('../Utilities/defineLazyObjectProperty');
const defineLazyObjectProperty =
require('../Utilities/defineLazyObjectProperty').default;
const Platform = require('../Utilities/Platform');
const UIManagerProperties = require('./UIManagerProperties').default;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ module.exports = {
get deepFreezeAndThrowOnMutationInDev(): deepFreezeAndThrowOnMutationInDev<
{...} | Array<mixed>,
> {
return require('../Utilities/deepFreezeAndThrowOnMutationInDev');
return require('../Utilities/deepFreezeAndThrowOnMutationInDev').default;
},
// TODO: Remove when React has migrated to `createAttributePayload` and `diffAttributePayloads`
get flattenStyle(): flattenStyle<DangerouslyImpreciseStyleProp> {
Expand Down
3 changes: 2 additions & 1 deletion packages/react-native/Libraries/UTFSequence.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@

'use strict';

const deepFreezeAndThrowOnMutationInDev = require('./Utilities/deepFreezeAndThrowOnMutationInDev');
const deepFreezeAndThrowOnMutationInDev =
require('./Utilities/deepFreezeAndThrowOnMutationInDev').default;

/**
* A collection of Unicode sequences for various characters and emoji.
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native/Libraries/Utilities/DeviceInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@

import NativeDeviceInfo from './NativeDeviceInfo';

module.exports = NativeDeviceInfo;
export default NativeDeviceInfo;
6 changes: 2 additions & 4 deletions packages/react-native/Libraries/Utilities/FeatureDetection.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,15 @@
* Note that a polyfill can technically fake this behavior but few does it.
* Therefore, this is usually good enough for our purpose.
*/
function isNativeFunction(f: Function): boolean {
export function isNativeFunction(f: Function): boolean {
return typeof f === 'function' && f.toString().indexOf('[native code]') > -1;
}

/**
* @return whether or not the constructor of @param {object} o is an native
* function named with @param {string} expectedName.
*/
function hasNativeConstructor(o: Object, expectedName: string): boolean {
export function hasNativeConstructor(o: Object, expectedName: string): boolean {
const con = Object.getPrototypeOf(o).constructor;
return con.name === expectedName && isNativeFunction(con);
}

module.exports = {isNativeFunction, hasNativeConstructor};
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

'use strict';

const defineLazyObjectProperty = require('./defineLazyObjectProperty');
const defineLazyObjectProperty = require('./defineLazyObjectProperty').default;

/**
* Sets an object's property. If a property with the same name exists, this will
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
'use strict';

describe('DeviceInfo', () => {
const DeviceInfo = require('../DeviceInfo');
const DeviceInfo = require('../DeviceInfo').default;

it('should give device info', () => {
expect(DeviceInfo.getConstants()).toHaveProperty('Dimensions');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
* @oncall react_native
*/

const deepFreezeAndThrowOnMutationInDev = require('../deepFreezeAndThrowOnMutationInDev');
const deepFreezeAndThrowOnMutationInDev =
require('../deepFreezeAndThrowOnMutationInDev').default;

describe('deepFreezeAndThrowOnMutationInDev', function () {
it('should be a noop on non object values', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,4 @@ function identity(value: mixed) {
return value;
}

module.exports = deepFreezeAndThrowOnMutationInDev;
export default deepFreezeAndThrowOnMutationInDev;
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,4 @@ function defineLazyObjectProperty<T>(
});
}

module.exports = defineLazyObjectProperty;
export default defineLazyObjectProperty;
Original file line number Diff line number Diff line change
Expand Up @@ -8130,7 +8130,7 @@ declare module.exports: DevSettings;
`;

exports[`public API should not change unintentionally Libraries/Utilities/DeviceInfo.js 1`] = `
"declare module.exports: NativeDeviceInfo;
"declare export default typeof NativeDeviceInfo;
"
`;

Expand All @@ -8145,12 +8145,11 @@ declare export default typeof Dimensions;
`;

exports[`public API should not change unintentionally Libraries/Utilities/FeatureDetection.js 1`] = `
"declare function isNativeFunction(f: Function): boolean;
declare function hasNativeConstructor(o: Object, expectedName: string): boolean;
declare module.exports: {
isNativeFunction: isNativeFunction,
hasNativeConstructor: hasNativeConstructor,
};
"declare export function isNativeFunction(f: Function): boolean;
declare export function hasNativeConstructor(
o: Object,
expectedName: string
): boolean;
"
`;

Expand Down Expand Up @@ -8482,7 +8481,7 @@ exports[`public API should not change unintentionally Libraries/Utilities/deepFr
"declare function deepFreezeAndThrowOnMutationInDev<T: { ... } | Array<mixed>>(
object: T
): T;
declare module.exports: deepFreezeAndThrowOnMutationInDev;
declare export default typeof deepFreezeAndThrowOnMutationInDev;
"
`;

Expand All @@ -8497,7 +8496,7 @@ exports[`public API should not change unintentionally Libraries/Utilities/define
...
}
): void;
declare module.exports: defineLazyObjectProperty;
declare export default typeof defineLazyObjectProperty;
"
`;

Expand Down
2 changes: 1 addition & 1 deletion packages/react-native/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ module.exports = {
return require('./Libraries/Components/Clipboard/Clipboard').default;
},
get DeviceInfo(): DeviceInfo {
return require('./Libraries/Utilities/DeviceInfo');
return require('./Libraries/Utilities/DeviceInfo').default;
},
get DevMenu(): DevMenu {
return require('./src/private/devmenu/DevMenu');
Expand Down