Skip to content

Commit 161b910

Browse files
NickGerlemanfacebook-github-bot
authored andcommitted
Do not explicitly include ".js" in Library imports (#28311)
Summary: A few recent imports have explicitly added ".js" to the end of their path. This prevents Metro from resolving platform-specific JS files, e.g. "Foo.android.js" or "Foo.windows.js" instead of "Foo.js". React Native Windows provides its own implementation of files in a few cases where stock React Native will share them between Android and iOS. We hope to reduce/eliminate these long term, but requiring explicit ".js" files currently breaks us in a couple of places where we have custom implementations. This change is a quick regex replace of ES6 and CommonJS imports in 'Libraries/" to eliminate ".js". ## Changelog [General] [Fixed] - Do not explicitly include ".js" in Library imports Pull Request resolved: #28311 Test Plan: I haven't done any manual validation of this, but `flow-check` should catch any issues with this during CI. Reviewed By: cpojer Differential Revision: D20486466 Pulled By: TheSavior fbshipit-source-id: 31e1ccc307967417d7d09c34c859f0b2b69eac84
1 parent 4482e53 commit 161b910

19 files changed

+50
-50
lines changed

Libraries/Components/Pressable/Pressable.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,18 @@
1212

1313
import * as React from 'react';
1414
import {useMemo, useState, useRef, useImperativeHandle} from 'react';
15-
import useAndroidRippleForView from './useAndroidRippleForView.js';
15+
import useAndroidRippleForView from './useAndroidRippleForView';
1616
import type {
1717
AccessibilityActionEvent,
1818
AccessibilityActionInfo,
1919
AccessibilityRole,
2020
AccessibilityState,
2121
AccessibilityValue,
22-
} from '../View/ViewAccessibility.js';
23-
import usePressability from '../../Pressability/usePressability.js';
24-
import {normalizeRect, type RectOrSize} from '../../StyleSheet/Rect.js';
25-
import type {ColorValue} from '../../StyleSheet/StyleSheetTypes.js';
26-
import type {LayoutEvent, PressEvent} from '../../Types/CoreEventTypes.js';
22+
} from '../View/ViewAccessibility';
23+
import usePressability from '../../Pressability/usePressability';
24+
import {normalizeRect, type RectOrSize} from '../../StyleSheet/Rect';
25+
import type {ColorValue} from '../../StyleSheet/StyleSheetTypes';
26+
import type {LayoutEvent, PressEvent} from '../../Types/CoreEventTypes';
2727
import View from '../View/View';
2828

2929
type ViewStyleProp = $ElementType<React.ElementConfig<typeof View>, 'style'>;

Libraries/Components/Pressable/useAndroidRippleForView.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
'use strict';
1212

1313
import invariant from 'invariant';
14-
import {Commands} from '../View/ViewNativeComponent.js';
15-
import type {ColorValue} from '../../StyleSheet/StyleSheetTypes.js';
16-
import type {PressEvent} from '../../Types/CoreEventTypes.js';
14+
import {Commands} from '../View/ViewNativeComponent';
15+
import type {ColorValue} from '../../StyleSheet/StyleSheetTypes';
16+
import type {PressEvent} from '../../Types/CoreEventTypes';
1717
import {Platform, View, processColor} from 'react-native';
1818
import * as React from 'react';
1919
import {useMemo} from 'react';

Libraries/Components/TextInput/TextInput.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ if (Platform.OS === 'android') {
4545
AndroidTextInputCommands = require('./AndroidTextInputNativeComponent')
4646
.Commands;
4747
} else if (Platform.OS === 'ios') {
48-
RCTMultilineTextInputView = require('./RCTMultilineTextInputNativeComponent.js')
48+
RCTMultilineTextInputView = require('./RCTMultilineTextInputNativeComponent')
4949
.default;
50-
RCTSinglelineTextInputView = require('./RCTSingelineTextInputNativeComponent.js')
50+
RCTSinglelineTextInputView = require('./RCTSingelineTextInputNativeComponent')
5151
.default;
5252
}
5353

Libraries/Components/Touchable/TVTouchable.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
'use strict';
1212

1313
import invariant from 'invariant';
14-
import ReactNative from '../../Renderer/shims/ReactNative.js';
14+
import ReactNative from '../../Renderer/shims/ReactNative';
1515
import type {
1616
BlurEvent,
1717
FocusEvent,

Libraries/Components/Touchable/TouchableBounce.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212

1313
import Pressability, {
1414
type PressabilityConfig,
15-
} from '../../Pressability/Pressability.js';
16-
import {PressabilityDebugView} from '../../Pressability/PressabilityDebug.js';
17-
import type {ViewStyleProp} from '../../StyleSheet/StyleSheet.js';
18-
import TVTouchable from './TVTouchable.js';
19-
import typeof TouchableWithoutFeedback from './TouchableWithoutFeedback.js';
15+
} from '../../Pressability/Pressability';
16+
import {PressabilityDebugView} from '../../Pressability/PressabilityDebug';
17+
import type {ViewStyleProp} from '../../StyleSheet/StyleSheet';
18+
import TVTouchable from './TVTouchable';
19+
import typeof TouchableWithoutFeedback from './TouchableWithoutFeedback';
2020
import {Animated, Platform} from 'react-native';
2121
import * as React from 'react';
2222

Libraries/Components/Touchable/TouchableHighlight.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212

1313
import Pressability, {
1414
type PressabilityConfig,
15-
} from '../../Pressability/Pressability.js';
16-
import {PressabilityDebugView} from '../../Pressability/PressabilityDebug.js';
17-
import StyleSheet, {type ViewStyleProp} from '../../StyleSheet/StyleSheet.js';
18-
import type {ColorValue} from '../../StyleSheet/StyleSheetTypes.js';
19-
import TVTouchable from './TVTouchable.js';
20-
import typeof TouchableWithoutFeedback from './TouchableWithoutFeedback.js';
15+
} from '../../Pressability/Pressability';
16+
import {PressabilityDebugView} from '../../Pressability/PressabilityDebug';
17+
import StyleSheet, {type ViewStyleProp} from '../../StyleSheet/StyleSheet';
18+
import type {ColorValue} from '../../StyleSheet/StyleSheetTypes';
19+
import TVTouchable from './TVTouchable';
20+
import typeof TouchableWithoutFeedback from './TouchableWithoutFeedback';
2121
import Platform from '../../Utilities/Platform';
2222
import View from '../../Components/View/View';
2323
import * as React from 'react';

Libraries/Components/Touchable/TouchableNativeFeedback.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212

1313
import Pressability, {
1414
type PressabilityConfig,
15-
} from '../../Pressability/Pressability.js';
16-
import {PressabilityDebugView} from '../../Pressability/PressabilityDebug.js';
17-
import TVTouchable from './TVTouchable.js';
18-
import typeof TouchableWithoutFeedback from './TouchableWithoutFeedback.js';
15+
} from '../../Pressability/Pressability';
16+
import {PressabilityDebugView} from '../../Pressability/PressabilityDebug';
17+
import TVTouchable from './TVTouchable';
18+
import typeof TouchableWithoutFeedback from './TouchableWithoutFeedback';
1919
import {Commands} from 'react-native/Libraries/Components/View/ViewNativeComponent';
2020
import ReactNative from 'react-native/Libraries/Renderer/shims/ReactNative';
2121
import type {PressEvent} from 'react-native/Libraries/Types/CoreEventTypes';

Libraries/Components/Touchable/TouchableOpacity.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212

1313
import Pressability, {
1414
type PressabilityConfig,
15-
} from '../../Pressability/Pressability.js';
16-
import {PressabilityDebugView} from '../../Pressability/PressabilityDebug.js';
17-
import TVTouchable from './TVTouchable.js';
18-
import typeof TouchableWithoutFeedback from './TouchableWithoutFeedback.js';
15+
} from '../../Pressability/Pressability';
16+
import {PressabilityDebugView} from '../../Pressability/PressabilityDebug';
17+
import TVTouchable from './TVTouchable';
18+
import typeof TouchableWithoutFeedback from './TouchableWithoutFeedback';
1919
import Animated from 'react-native/Libraries/Animated/src/Animated';
2020
import Easing from 'react-native/Libraries/Animated/src/Easing';
2121
import type {ViewStyleProp} from 'react-native/Libraries/StyleSheet/StyleSheet';

Libraries/Components/Touchable/TouchableWithoutFeedback.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212

1313
import Pressability, {
1414
type PressabilityConfig,
15-
} from '../../Pressability/Pressability.js';
16-
import {PressabilityDebugView} from '../../Pressability/PressabilityDebug.js';
17-
import TVTouchable from './TVTouchable.js';
15+
} from '../../Pressability/Pressability';
16+
import {PressabilityDebugView} from '../../Pressability/PressabilityDebug';
17+
import TVTouchable from './TVTouchable';
1818
import type {
1919
AccessibilityActionEvent,
2020
AccessibilityActionInfo,

Libraries/Core/setUpReactDevTools.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ if (__DEV__) {
4141
const WebSocket = require('../WebSocket/WebSocket');
4242
const ws = new WebSocket('ws://' + host + ':' + port);
4343

44-
const viewConfig = require('../Components/View/ReactNativeViewViewConfig.js');
44+
const viewConfig = require('../Components/View/ReactNativeViewViewConfig');
4545
reactDevTools.connectToDevTools({
4646
isAppActive,
4747
resolveRNStyle: require('../StyleSheet/flattenStyle'),

Libraries/Inspector/Inspector.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const renderers = findRenderers();
3535
// Required for React DevTools to view/edit React Native styles in Flipper.
3636
// Flipper doesn't inject these values when initializing DevTools.
3737
hook.resolveRNStyle = require('../StyleSheet/flattenStyle');
38-
const viewConfig = require('../Components/View/ReactNativeViewViewConfig.js');
38+
const viewConfig = require('../Components/View/ReactNativeViewViewConfig');
3939
hook.nativeStyleEditorValidAttributes = Object.keys(
4040
viewConfig.validAttributes.style,
4141
);

Libraries/Lists/FlatList.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const invariant = require('invariant');
2222
import ScrollView, {
2323
type ScrollResponderType,
2424
} from '../Components/ScrollView/ScrollView';
25-
import type {ScrollViewNativeComponentType} from '../Components/ScrollView/ScrollViewNativeComponentType.js';
25+
import type {ScrollViewNativeComponentType} from '../Components/ScrollView/ScrollViewNativeComponentType';
2626
import type {ViewStyleProp} from '../StyleSheet/StyleSheet';
2727
import type {
2828
ViewToken,

Libraries/Pressability/Pressability.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@
1010

1111
'use strict';
1212

13-
import {isHoverEnabled} from './HoverState.js';
13+
import {isHoverEnabled} from './HoverState';
1414
import invariant from 'invariant';
15-
import SoundManager from '../Components/Sound/SoundManager.js';
16-
import {normalizeRect, type RectOrSize} from '../StyleSheet/Rect.js';
15+
import SoundManager from '../Components/Sound/SoundManager';
16+
import {normalizeRect, type RectOrSize} from '../StyleSheet/Rect';
1717
import type {
1818
BlurEvent,
1919
FocusEvent,
2020
PressEvent,
2121
MouseEvent,
22-
} from '../Types/CoreEventTypes.js';
22+
} from '../Types/CoreEventTypes';
2323
import Platform from '../Utilities/Platform';
2424
import UIManager from '../ReactNative/UIManager';
2525
import type {HostComponent} from '../Renderer/shims/ReactNativeTypes';

Libraries/Pressability/PressabilityDebug.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
'use strict';
1212

13-
import normalizeColor from '../StyleSheet/normalizeColor.js';
13+
import normalizeColor from '../StyleSheet/normalizeColor';
1414
import type {ColorValue} from '../StyleSheet/StyleSheetTypes';
1515

1616
import Touchable from '../Components/Touchable/Touchable';

Libraries/Pressability/__tests__/Pressability-test.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111

1212
'use strict';
1313

14-
import type {PressEvent} from '../../Types/CoreEventTypes.js';
15-
import * as HoverState from '../HoverState.js';
16-
import Pressability from '../Pressability.js';
14+
import type {PressEvent} from '../../Types/CoreEventTypes';
15+
import * as HoverState from '../HoverState';
16+
import Pressability from '../Pressability';
1717
import invariant from 'invariant';
1818
import nullthrows from 'nullthrows';
1919
import Platform from '../../Utilities/Platform';

Libraries/Pressability/usePressability.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import Pressability, {
1414
type EventHandlers,
1515
type PressabilityConfig,
16-
} from './Pressability.js';
16+
} from './Pressability';
1717
import {useEffect, useRef} from 'react';
1818

1919
export default function usePressability(

Libraries/ReactPrivate/ReactNativePrivateInterface.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* @flow strict-local
99
*/
1010

11-
import typeof BatchedBridge from '../BatchedBridge/BatchedBridge.js';
11+
import typeof BatchedBridge from '../BatchedBridge/BatchedBridge';
1212
import typeof ExceptionsManager from '../Core/ExceptionsManager';
1313
import typeof Platform from '../Utilities/Platform';
1414
import typeof RCTEventEmitter from '../EventEmitter/RCTEventEmitter';
@@ -23,7 +23,7 @@ import typeof ReactFiberErrorDialog from '../Core/ReactFiberErrorDialog';
2323
// flowlint unsafe-getters-setters:off
2424
module.exports = {
2525
get BatchedBridge(): BatchedBridge {
26-
return require('../BatchedBridge/BatchedBridge.js');
26+
return require('../BatchedBridge/BatchedBridge');
2727
},
2828
get ExceptionsManager(): ExceptionsManager {
2929
return require('../Core/ExceptionsManager');

Libraries/StyleSheet/EdgeInsetsPropType.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@
1010

1111
'use strict';
1212

13-
import type {Rect} from './Rect.js';
13+
import type {Rect} from './Rect';
1414

1515
export type EdgeInsetsProp = Rect;

Libraries/vendor/core/ErrorUtils.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* @flow strict
99
*/
1010

11-
import type {ErrorUtilsT} from '../../polyfills/error-guard.js';
11+
import type {ErrorUtilsT} from '../../polyfills/error-guard';
1212

1313
/**
1414
* The particular require runtime that we are using looks for a global

0 commit comments

Comments
 (0)