Skip to content

Commit

Permalink
Migrate "Libraries" from Haste to standard path-based requires (sans …
Browse files Browse the repository at this point in the history
…vendor & renderers) (#24749)

Summary:
This is the next step in moving RN towards standard path-based requires. All the requires in `Libraries` have been rewritten to use relative requires with a few exceptions, namely, `vendor` and `Renderer/oss` since those need to be changed upstream. This commit uses relative requires instead of `react-native/...` so that if Facebook were to stop syncing out certain folders and therefore remove code from the react-native package, internal code at Facebook would not need to change.

See the umbrella issue at #24316 for more detail.

[General] [Changed] - Migrate "Libraries" from Haste to standard path-based requires
Pull Request resolved: #24749

Differential Revision: D15258017

Pulled By: cpojer

fbshipit-source-id: a1f480ea36c05c659b6f37c8f02f6f9216d5a323
  • Loading branch information
ide authored and facebook-github-bot committed May 8, 2019
1 parent 59749f5 commit 0ee5f68
Show file tree
Hide file tree
Showing 374 changed files with 1,474 additions and 1,398 deletions.
10 changes: 5 additions & 5 deletions Libraries/ART/ReactNativeART.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
'use strict';

const Color = require('art/core/color');
const Path = require('ARTSerializablePath');
const Path = require('./ARTSerializablePath');
const Transform = require('art/core/transform');

const React = require('React');
const React = require('react');
const PropTypes = require('prop-types');
const ReactNativeViewAttributes = require('ReactNativeViewAttributes');
const ReactNativeViewAttributes = require('../Components/View/ReactNativeViewAttributes');

const createReactNativeComponentClass = require('createReactNativeComponentClass');
const merge = require('merge');
const createReactNativeComponentClass = require('../Renderer/shims/createReactNativeComponentClass');
const merge = require('../vendor/core/merge');
const invariant = require('invariant');

// Diff Helpers
Expand Down
5 changes: 3 additions & 2 deletions Libraries/ActionSheetIOS/ActionSheetIOS.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@
*/
'use strict';

const RCTActionSheetManager = require('NativeModules').ActionSheetManager;
const RCTActionSheetManager = require('../BatchedBridge/NativeModules')
.ActionSheetManager;

const invariant = require('invariant');
const processColor = require('processColor');
const processColor = require('../StyleSheet/processColor');

/**
* Display action sheets and share sheets on iOS.
Expand Down
4 changes: 2 additions & 2 deletions Libraries/Alert/Alert.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

'use strict';

const NativeModules = require('NativeModules');
const NativeModules = require('../BatchedBridge/NativeModules');
const RCTAlertManager = NativeModules.AlertManager;
const Platform = require('Platform');
const Platform = require('../Utilities/Platform');

export type Buttons = Array<{
text?: string,
Expand Down
2 changes: 1 addition & 1 deletion Libraries/Alert/RCTAlertManager.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

'use strict';

const NativeModules = require('NativeModules');
const NativeModules = require('../BatchedBridge/NativeModules');

function emptyCallback() {}

Expand Down
2 changes: 1 addition & 1 deletion Libraries/Alert/RCTAlertManager.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@

'use strict';

const RCTAlertManager = require('NativeModules').AlertManager;
const RCTAlertManager = require('../BatchedBridge/NativeModules').AlertManager;

module.exports = RCTAlertManager;
18 changes: 9 additions & 9 deletions Libraries/Animated/src/Animated.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,30 @@

'use strict';

import Platform from 'Platform';
import Platform from '../../Utilities/Platform';

const AnimatedImplementation = Platform.isTesting
? require('AnimatedMock')
: require('AnimatedImplementation');
? require('./AnimatedMock')
: require('./AnimatedImplementation');

module.exports = {
get FlatList() {
return require('AnimatedFlatList');
return require('./components/AnimatedFlatList');
},
get Image() {
return require('AnimatedImage');
return require('./components/AnimatedImage');
},
get ScrollView() {
return require('AnimatedScrollView');
return require('./components/AnimatedScrollView');
},
get SectionList() {
return require('AnimatedSectionList');
return require('./components/AnimatedSectionList');
},
get Text() {
return require('AnimatedText');
return require('./components/AnimatedText');
},
get View() {
return require('AnimatedView');
return require('./components/AnimatedView');
},
...AnimatedImplementation,
};
2 changes: 1 addition & 1 deletion Libraries/Animated/src/AnimatedEvent.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

const AnimatedValue = require('./nodes/AnimatedValue');
const NativeAnimatedHelper = require('./NativeAnimatedHelper');
const ReactNative = require('ReactNative');
const ReactNative = require('../../Renderer/shims/ReactNative');

const invariant = require('invariant');
const {shouldUseNativeDriver} = require('./NativeAnimatedHelper');
Expand Down
2 changes: 1 addition & 1 deletion Libraries/Animated/src/AnimatedMock.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
'use strict';

const {AnimatedEvent, attachNativeEvent} = require('./AnimatedEvent');
const AnimatedImplementation = require('AnimatedImplementation');
const AnimatedImplementation = require('./AnimatedImplementation');
const AnimatedInterpolation = require('./nodes/AnimatedInterpolation');
const AnimatedNode = require('./nodes/AnimatedNode');
const AnimatedProps = require('./nodes/AnimatedProps');
Expand Down
2 changes: 1 addition & 1 deletion Libraries/Animated/src/AnimatedWeb.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

'use strict';

const AnimatedImplementation = require('AnimatedImplementation');
const AnimatedImplementation = require('./AnimatedImplementation');

module.exports = {
...AnimatedImplementation,
Expand Down
2 changes: 1 addition & 1 deletion Libraries/Animated/src/Easing.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ class Easing {
x2: number,
y2: number,
): (t: number) => number {
const _bezier = require('bezier');
const _bezier = require('./bezier');
return _bezier(x1, y1, x2, y2);
}

Expand Down
5 changes: 3 additions & 2 deletions Libraries/Animated/src/NativeAnimatedHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
*/
'use strict';

const NativeAnimatedModule = require('NativeModules').NativeAnimatedModule;
const NativeEventEmitter = require('NativeEventEmitter');
const NativeAnimatedModule = require('../../BatchedBridge/NativeModules')
.NativeAnimatedModule;
const NativeEventEmitter = require('../../EventEmitter/NativeEventEmitter');

const invariant = require('invariant');

Expand Down
10 changes: 5 additions & 5 deletions Libraries/Animated/src/__tests__/Animated-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

'use strict';

let Animated = require('Animated');
let Animated = require('../Animated');
describe('Animated tests', () => {
beforeEach(() => {
jest.resetModules();
Expand Down Expand Up @@ -645,13 +645,13 @@ describe('Animated tests', () => {
let InteractionManager;

beforeEach(() => {
jest.mock('InteractionManager');
Animated = require('Animated');
InteractionManager = require('InteractionManager');
jest.mock('../../../Interaction/InteractionManager');
Animated = require('../Animated');
InteractionManager = require('../../../Interaction/InteractionManager');
});

afterEach(() => {
jest.unmock('InteractionManager');
jest.unmock('../../../Interaction/InteractionManager');
});

it('registers an interaction by default', () => {
Expand Down
4 changes: 2 additions & 2 deletions Libraries/Animated/src/__tests__/AnimatedMock-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

'use strict';

const AnimatedMock = require('AnimatedMock');
const AnimatedImplementation = require('AnimatedImplementation');
const AnimatedMock = require('../AnimatedMock');
const AnimatedImplementation = require('../AnimatedImplementation');

describe('Animated Mock', () => {
it('matches implementation keys', () => {
Expand Down
27 changes: 14 additions & 13 deletions Libraries/Animated/src/__tests__/AnimatedNative-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,22 @@ ClassComponentMock.prototype.isReactComponent = true;

jest
.clearAllMocks()
.setMock('Text', ClassComponentMock)
.setMock('View', ClassComponentMock)
.setMock('Image', ClassComponentMock)
.setMock('ScrollView', ClassComponentMock)
.setMock('FlatList', ClassComponentMock)
.setMock('SectionList', ClassComponentMock)
.setMock('React', {Component: class {}})
.setMock('NativeModules', {
.setMock('../../../Text/Text', ClassComponentMock)
.setMock('../../../Components/View/View', ClassComponentMock)
.setMock('../../../Image/Image', ClassComponentMock)
.setMock('../../../Components/ScrollView/ScrollView', ClassComponentMock)
.setMock('../../../Lists/FlatList', ClassComponentMock)
.setMock('../../../Lists/SectionList', ClassComponentMock)
.setMock('react', {Component: class {}})
.setMock('../../../BatchedBridge/NativeModules', {
NativeAnimatedModule: {},
})
.mock('NativeEventEmitter')
.mock('../../../EventEmitter/NativeEventEmitter')
// findNodeHandle is imported from ReactNative so mock that whole module.
.setMock('ReactNative', {findNodeHandle: () => 1});
.setMock('../../../Renderer/shims/ReactNative', {findNodeHandle: () => 1});

const Animated = require('Animated');
const NativeAnimatedHelper = require('NativeAnimatedHelper');
const Animated = require('../Animated');
const NativeAnimatedHelper = require('../NativeAnimatedHelper');

function createAndMountComponent(ComponentClass, props) {
const component = new ComponentClass();
Expand All @@ -43,7 +43,8 @@ function createAndMountComponent(ComponentClass, props) {
}

describe('Native Animated', () => {
const nativeAnimatedModule = require('NativeModules').NativeAnimatedModule;
const nativeAnimatedModule = require('../../../BatchedBridge/NativeModules')
.NativeAnimatedModule;

beforeEach(() => {
nativeAnimatedModule.addAnimatedEventToView = jest.fn();
Expand Down
2 changes: 1 addition & 1 deletion Libraries/Animated/src/__tests__/Easing-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

'use strict';

const Easing = require('Easing');
const Easing = require('../Easing');
describe('Easing', () => {
it('should work with linear', () => {
const easing = Easing.linear;
Expand Down
2 changes: 1 addition & 1 deletion Libraries/Animated/src/__tests__/Interpolation-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
'use strict';

const AnimatedInterpolation = require('../nodes/AnimatedInterpolation');
const Easing = require('Easing');
const Easing = require('../Easing');

describe('Interpolation', () => {
it('should work with defaults', () => {
Expand Down
2 changes: 1 addition & 1 deletion Libraries/Animated/src/__tests__/bezier-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

'use strict';

const bezier = require('bezier');
const bezier = require('../bezier');

const identity = function(x) {
return x;
Expand Down
2 changes: 1 addition & 1 deletion Libraries/Animated/src/animations/Animation.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/
'use strict';

const NativeAnimatedHelper = require('NativeAnimatedHelper');
const NativeAnimatedHelper = require('../NativeAnimatedHelper');

import type AnimatedValue from '../nodes/AnimatedValue';

Expand Down
2 changes: 1 addition & 1 deletion Libraries/Animated/src/animations/TimingAnimation.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export type TimingAnimationConfigSingle = AnimationConfig & {
let _easeInOut;
function easeInOut() {
if (!_easeInOut) {
const Easing = require('Easing');
const Easing = require('../Easing');
_easeInOut = Easing.inOut(Easing.ease);
}
return _easeInOut;
Expand Down
4 changes: 2 additions & 2 deletions Libraries/Animated/src/components/AnimatedFlatList.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

'use strict';

const FlatList = require('FlatList');
const FlatList = require('../../../Lists/FlatList');

const createAnimatedComponent = require('createAnimatedComponent');
const createAnimatedComponent = require('../createAnimatedComponent');

module.exports = createAnimatedComponent(FlatList);
4 changes: 2 additions & 2 deletions Libraries/Animated/src/components/AnimatedImage.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

'use strict';

const Image = require('Image');
const Image = require('../../../Image/Image');

const createAnimatedComponent = require('createAnimatedComponent');
const createAnimatedComponent = require('../createAnimatedComponent');

module.exports = createAnimatedComponent(Image);
4 changes: 2 additions & 2 deletions Libraries/Animated/src/components/AnimatedScrollView.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

'use strict';

const ScrollView = require('ScrollView');
const ScrollView = require('../../../Components/ScrollView/ScrollView');

const createAnimatedComponent = require('createAnimatedComponent');
const createAnimatedComponent = require('../createAnimatedComponent');

module.exports = createAnimatedComponent(ScrollView, {
scrollEventThrottle: 0.0001,
Expand Down
4 changes: 2 additions & 2 deletions Libraries/Animated/src/components/AnimatedSectionList.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

'use strict';

const SectionList = require('SectionList');
const SectionList = require('../../../Lists/SectionList');

const createAnimatedComponent = require('createAnimatedComponent');
const createAnimatedComponent = require('../createAnimatedComponent');

module.exports = createAnimatedComponent(SectionList);
4 changes: 2 additions & 2 deletions Libraries/Animated/src/components/AnimatedText.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

'use strict';

const Text = require('Text');
const Text = require('../../../Text/Text');

const createAnimatedComponent = require('createAnimatedComponent');
const createAnimatedComponent = require('../createAnimatedComponent');

module.exports = createAnimatedComponent(Text);
4 changes: 2 additions & 2 deletions Libraries/Animated/src/components/AnimatedView.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

'use strict';

const View = require('View');
const View = require('../../../Components/View/View');

const createAnimatedComponent = require('createAnimatedComponent');
const createAnimatedComponent = require('../createAnimatedComponent');

module.exports = createAnimatedComponent(View);
4 changes: 2 additions & 2 deletions Libraries/Animated/src/createAnimatedComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

const {AnimatedEvent} = require('./AnimatedEvent');
const AnimatedProps = require('./nodes/AnimatedProps');
const React = require('React');
const DeprecatedViewStylePropTypes = require('DeprecatedViewStylePropTypes');
const React = require('react');
const DeprecatedViewStylePropTypes = require('../../DeprecatedPropTypes/DeprecatedViewStylePropTypes');

const invariant = require('invariant');

Expand Down
2 changes: 1 addition & 1 deletion Libraries/Animated/src/nodes/AnimatedInterpolation.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const AnimatedWithChildren = require('./AnimatedWithChildren');
const NativeAnimatedHelper = require('../NativeAnimatedHelper');

const invariant = require('invariant');
const normalizeColor = require('normalizeColor');
const normalizeColor = require('../../../Color/normalizeColor');

type ExtrapolateType = 'extend' | 'identity' | 'clamp';

Expand Down
2 changes: 1 addition & 1 deletion Libraries/Animated/src/nodes/AnimatedProps.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const {AnimatedEvent} = require('../AnimatedEvent');
const AnimatedNode = require('./AnimatedNode');
const AnimatedStyle = require('./AnimatedStyle');
const NativeAnimatedHelper = require('../NativeAnimatedHelper');
const ReactNative = require('ReactNative');
const ReactNative = require('../../../Renderer/shims/ReactNative');

const invariant = require('invariant');

Expand Down
2 changes: 1 addition & 1 deletion Libraries/Animated/src/nodes/AnimatedStyle.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const AnimatedTransform = require('./AnimatedTransform');
const AnimatedWithChildren = require('./AnimatedWithChildren');
const NativeAnimatedHelper = require('../NativeAnimatedHelper');

const flattenStyle = require('flattenStyle');
const flattenStyle = require('../../../StyleSheet/flattenStyle');

class AnimatedStyle extends AnimatedWithChildren {
_style: Object;
Expand Down
2 changes: 1 addition & 1 deletion Libraries/Animated/src/nodes/AnimatedValue.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

const AnimatedInterpolation = require('./AnimatedInterpolation');
const AnimatedWithChildren = require('./AnimatedWithChildren');
const InteractionManager = require('InteractionManager');
const InteractionManager = require('../../../Interaction/InteractionManager');
const NativeAnimatedHelper = require('../NativeAnimatedHelper');

import type Animation, {EndCallback} from '../animations/Animation';
Expand Down
Loading

0 comments on commit 0ee5f68

Please sign in to comment.