Skip to content

Commit

Permalink
Do not explicitly include ".js" in Library imports (#28311)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
NickGerleman authored and facebook-github-bot committed Mar 17, 2020
1 parent 4482e53 commit 161b910
Showing 19 changed files with 50 additions and 50 deletions.
12 changes: 6 additions & 6 deletions Libraries/Components/Pressable/Pressable.js
Original file line number Diff line number Diff line change
@@ -12,18 +12,18 @@

import * as React from 'react';
import {useMemo, useState, useRef, useImperativeHandle} from 'react';
import useAndroidRippleForView from './useAndroidRippleForView.js';
import useAndroidRippleForView from './useAndroidRippleForView';
import type {
AccessibilityActionEvent,
AccessibilityActionInfo,
AccessibilityRole,
AccessibilityState,
AccessibilityValue,
} from '../View/ViewAccessibility.js';
import usePressability from '../../Pressability/usePressability.js';
import {normalizeRect, type RectOrSize} from '../../StyleSheet/Rect.js';
import type {ColorValue} from '../../StyleSheet/StyleSheetTypes.js';
import type {LayoutEvent, PressEvent} from '../../Types/CoreEventTypes.js';
} from '../View/ViewAccessibility';
import usePressability from '../../Pressability/usePressability';
import {normalizeRect, type RectOrSize} from '../../StyleSheet/Rect';
import type {ColorValue} from '../../StyleSheet/StyleSheetTypes';
import type {LayoutEvent, PressEvent} from '../../Types/CoreEventTypes';
import View from '../View/View';

type ViewStyleProp = $ElementType<React.ElementConfig<typeof View>, 'style'>;
6 changes: 3 additions & 3 deletions Libraries/Components/Pressable/useAndroidRippleForView.js
Original file line number Diff line number Diff line change
@@ -11,9 +11,9 @@
'use strict';

import invariant from 'invariant';
import {Commands} from '../View/ViewNativeComponent.js';
import type {ColorValue} from '../../StyleSheet/StyleSheetTypes.js';
import type {PressEvent} from '../../Types/CoreEventTypes.js';
import {Commands} from '../View/ViewNativeComponent';
import type {ColorValue} from '../../StyleSheet/StyleSheetTypes';
import type {PressEvent} from '../../Types/CoreEventTypes';
import {Platform, View, processColor} from 'react-native';
import * as React from 'react';
import {useMemo} from 'react';
4 changes: 2 additions & 2 deletions Libraries/Components/TextInput/TextInput.js
Original file line number Diff line number Diff line change
@@ -45,9 +45,9 @@ if (Platform.OS === 'android') {
AndroidTextInputCommands = require('./AndroidTextInputNativeComponent')
.Commands;
} else if (Platform.OS === 'ios') {
RCTMultilineTextInputView = require('./RCTMultilineTextInputNativeComponent.js')
RCTMultilineTextInputView = require('./RCTMultilineTextInputNativeComponent')
.default;
RCTSinglelineTextInputView = require('./RCTSingelineTextInputNativeComponent.js')
RCTSinglelineTextInputView = require('./RCTSingelineTextInputNativeComponent')
.default;
}

2 changes: 1 addition & 1 deletion Libraries/Components/Touchable/TVTouchable.js
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@
'use strict';

import invariant from 'invariant';
import ReactNative from '../../Renderer/shims/ReactNative.js';
import ReactNative from '../../Renderer/shims/ReactNative';
import type {
BlurEvent,
FocusEvent,
10 changes: 5 additions & 5 deletions Libraries/Components/Touchable/TouchableBounce.js
Original file line number Diff line number Diff line change
@@ -12,11 +12,11 @@

import Pressability, {
type PressabilityConfig,
} from '../../Pressability/Pressability.js';
import {PressabilityDebugView} from '../../Pressability/PressabilityDebug.js';
import type {ViewStyleProp} from '../../StyleSheet/StyleSheet.js';
import TVTouchable from './TVTouchable.js';
import typeof TouchableWithoutFeedback from './TouchableWithoutFeedback.js';
} from '../../Pressability/Pressability';
import {PressabilityDebugView} from '../../Pressability/PressabilityDebug';
import type {ViewStyleProp} from '../../StyleSheet/StyleSheet';
import TVTouchable from './TVTouchable';
import typeof TouchableWithoutFeedback from './TouchableWithoutFeedback';
import {Animated, Platform} from 'react-native';
import * as React from 'react';

12 changes: 6 additions & 6 deletions Libraries/Components/Touchable/TouchableHighlight.js
Original file line number Diff line number Diff line change
@@ -12,12 +12,12 @@

import Pressability, {
type PressabilityConfig,
} from '../../Pressability/Pressability.js';
import {PressabilityDebugView} from '../../Pressability/PressabilityDebug.js';
import StyleSheet, {type ViewStyleProp} from '../../StyleSheet/StyleSheet.js';
import type {ColorValue} from '../../StyleSheet/StyleSheetTypes.js';
import TVTouchable from './TVTouchable.js';
import typeof TouchableWithoutFeedback from './TouchableWithoutFeedback.js';
} from '../../Pressability/Pressability';
import {PressabilityDebugView} from '../../Pressability/PressabilityDebug';
import StyleSheet, {type ViewStyleProp} from '../../StyleSheet/StyleSheet';
import type {ColorValue} from '../../StyleSheet/StyleSheetTypes';
import TVTouchable from './TVTouchable';
import typeof TouchableWithoutFeedback from './TouchableWithoutFeedback';
import Platform from '../../Utilities/Platform';
import View from '../../Components/View/View';
import * as React from 'react';
8 changes: 4 additions & 4 deletions Libraries/Components/Touchable/TouchableNativeFeedback.js
Original file line number Diff line number Diff line change
@@ -12,10 +12,10 @@

import Pressability, {
type PressabilityConfig,
} from '../../Pressability/Pressability.js';
import {PressabilityDebugView} from '../../Pressability/PressabilityDebug.js';
import TVTouchable from './TVTouchable.js';
import typeof TouchableWithoutFeedback from './TouchableWithoutFeedback.js';
} from '../../Pressability/Pressability';
import {PressabilityDebugView} from '../../Pressability/PressabilityDebug';
import TVTouchable from './TVTouchable';
import typeof TouchableWithoutFeedback from './TouchableWithoutFeedback';
import {Commands} from 'react-native/Libraries/Components/View/ViewNativeComponent';
import ReactNative from 'react-native/Libraries/Renderer/shims/ReactNative';
import type {PressEvent} from 'react-native/Libraries/Types/CoreEventTypes';
8 changes: 4 additions & 4 deletions Libraries/Components/Touchable/TouchableOpacity.js
Original file line number Diff line number Diff line change
@@ -12,10 +12,10 @@

import Pressability, {
type PressabilityConfig,
} from '../../Pressability/Pressability.js';
import {PressabilityDebugView} from '../../Pressability/PressabilityDebug.js';
import TVTouchable from './TVTouchable.js';
import typeof TouchableWithoutFeedback from './TouchableWithoutFeedback.js';
} from '../../Pressability/Pressability';
import {PressabilityDebugView} from '../../Pressability/PressabilityDebug';
import TVTouchable from './TVTouchable';
import typeof TouchableWithoutFeedback from './TouchableWithoutFeedback';
import Animated from 'react-native/Libraries/Animated/src/Animated';
import Easing from 'react-native/Libraries/Animated/src/Easing';
import type {ViewStyleProp} from 'react-native/Libraries/StyleSheet/StyleSheet';
6 changes: 3 additions & 3 deletions Libraries/Components/Touchable/TouchableWithoutFeedback.js
Original file line number Diff line number Diff line change
@@ -12,9 +12,9 @@

import Pressability, {
type PressabilityConfig,
} from '../../Pressability/Pressability.js';
import {PressabilityDebugView} from '../../Pressability/PressabilityDebug.js';
import TVTouchable from './TVTouchable.js';
} from '../../Pressability/Pressability';
import {PressabilityDebugView} from '../../Pressability/PressabilityDebug';
import TVTouchable from './TVTouchable';
import type {
AccessibilityActionEvent,
AccessibilityActionInfo,
2 changes: 1 addition & 1 deletion Libraries/Core/setUpReactDevTools.js
Original file line number Diff line number Diff line change
@@ -41,7 +41,7 @@ if (__DEV__) {
const WebSocket = require('../WebSocket/WebSocket');
const ws = new WebSocket('ws://' + host + ':' + port);

const viewConfig = require('../Components/View/ReactNativeViewViewConfig.js');
const viewConfig = require('../Components/View/ReactNativeViewViewConfig');
reactDevTools.connectToDevTools({
isAppActive,
resolveRNStyle: require('../StyleSheet/flattenStyle'),
2 changes: 1 addition & 1 deletion Libraries/Inspector/Inspector.js
Original file line number Diff line number Diff line change
@@ -35,7 +35,7 @@ const renderers = findRenderers();
// Required for React DevTools to view/edit React Native styles in Flipper.
// Flipper doesn't inject these values when initializing DevTools.
hook.resolveRNStyle = require('../StyleSheet/flattenStyle');
const viewConfig = require('../Components/View/ReactNativeViewViewConfig.js');
const viewConfig = require('../Components/View/ReactNativeViewViewConfig');
hook.nativeStyleEditorValidAttributes = Object.keys(
viewConfig.validAttributes.style,
);
2 changes: 1 addition & 1 deletion Libraries/Lists/FlatList.js
Original file line number Diff line number Diff line change
@@ -22,7 +22,7 @@ const invariant = require('invariant');
import ScrollView, {
type ScrollResponderType,
} from '../Components/ScrollView/ScrollView';
import type {ScrollViewNativeComponentType} from '../Components/ScrollView/ScrollViewNativeComponentType.js';
import type {ScrollViewNativeComponentType} from '../Components/ScrollView/ScrollViewNativeComponentType';
import type {ViewStyleProp} from '../StyleSheet/StyleSheet';
import type {
ViewToken,
8 changes: 4 additions & 4 deletions Libraries/Pressability/Pressability.js
Original file line number Diff line number Diff line change
@@ -10,16 +10,16 @@

'use strict';

import {isHoverEnabled} from './HoverState.js';
import {isHoverEnabled} from './HoverState';
import invariant from 'invariant';
import SoundManager from '../Components/Sound/SoundManager.js';
import {normalizeRect, type RectOrSize} from '../StyleSheet/Rect.js';
import SoundManager from '../Components/Sound/SoundManager';
import {normalizeRect, type RectOrSize} from '../StyleSheet/Rect';
import type {
BlurEvent,
FocusEvent,
PressEvent,
MouseEvent,
} from '../Types/CoreEventTypes.js';
} from '../Types/CoreEventTypes';
import Platform from '../Utilities/Platform';
import UIManager from '../ReactNative/UIManager';
import type {HostComponent} from '../Renderer/shims/ReactNativeTypes';
2 changes: 1 addition & 1 deletion Libraries/Pressability/PressabilityDebug.js
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@

'use strict';

import normalizeColor from '../StyleSheet/normalizeColor.js';
import normalizeColor from '../StyleSheet/normalizeColor';
import type {ColorValue} from '../StyleSheet/StyleSheetTypes';

import Touchable from '../Components/Touchable/Touchable';
6 changes: 3 additions & 3 deletions Libraries/Pressability/__tests__/Pressability-test.js
Original file line number Diff line number Diff line change
@@ -11,9 +11,9 @@

'use strict';

import type {PressEvent} from '../../Types/CoreEventTypes.js';
import * as HoverState from '../HoverState.js';
import Pressability from '../Pressability.js';
import type {PressEvent} from '../../Types/CoreEventTypes';
import * as HoverState from '../HoverState';
import Pressability from '../Pressability';
import invariant from 'invariant';
import nullthrows from 'nullthrows';
import Platform from '../../Utilities/Platform';
2 changes: 1 addition & 1 deletion Libraries/Pressability/usePressability.js
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@
import Pressability, {
type EventHandlers,
type PressabilityConfig,
} from './Pressability.js';
} from './Pressability';
import {useEffect, useRef} from 'react';

export default function usePressability(
4 changes: 2 additions & 2 deletions Libraries/ReactPrivate/ReactNativePrivateInterface.js
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@
* @flow strict-local
*/

import typeof BatchedBridge from '../BatchedBridge/BatchedBridge.js';
import typeof BatchedBridge from '../BatchedBridge/BatchedBridge';
import typeof ExceptionsManager from '../Core/ExceptionsManager';
import typeof Platform from '../Utilities/Platform';
import typeof RCTEventEmitter from '../EventEmitter/RCTEventEmitter';
@@ -23,7 +23,7 @@ import typeof ReactFiberErrorDialog from '../Core/ReactFiberErrorDialog';
// flowlint unsafe-getters-setters:off
module.exports = {
get BatchedBridge(): BatchedBridge {
return require('../BatchedBridge/BatchedBridge.js');
return require('../BatchedBridge/BatchedBridge');
},
get ExceptionsManager(): ExceptionsManager {
return require('../Core/ExceptionsManager');
2 changes: 1 addition & 1 deletion Libraries/StyleSheet/EdgeInsetsPropType.js
Original file line number Diff line number Diff line change
@@ -10,6 +10,6 @@

'use strict';

import type {Rect} from './Rect.js';
import type {Rect} from './Rect';

export type EdgeInsetsProp = Rect;
2 changes: 1 addition & 1 deletion Libraries/vendor/core/ErrorUtils.js
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@
* @flow strict
*/

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

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

0 comments on commit 161b910

Please sign in to comment.