Skip to content

Commit b1288ef

Browse files
committed
[react-native] Rewrite Haste imports in RN shims to use paths instead
This commit is a follow-up to facebook#15604, which explains more of the rationale behind moving React Native to path-based imports and the work needed in the React repository. In that linked PR, the generated renderers were updated but not the shims; this commit updates the shims. Test Plan: Generated the renderers and shims with `yarn build` and then verified that the generated shims don't contain any Haste-style imports. Copied the renderers and shims into RN manually and launched the RNTester app to verify it loads end-to-end.
1 parent 025b07b commit b1288ef

File tree

4 files changed

+12
-10
lines changed

4 files changed

+12
-10
lines changed

scripts/rollup/shims/react-native/NativeMethodsMixin.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212

1313
const {
1414
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
15-
} = require('ReactNative');
15+
} = require('./ReactNative');
1616

17-
import type {NativeMethodsMixinType} from 'ReactNativeTypes';
17+
import type {NativeMethodsMixinType} from './ReactNativeTypes';
1818

1919
const {NativeMethodsMixin} = __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
2020

scripts/rollup/shims/react-native/ReactFabric.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@
1010

1111
'use strict';
1212

13-
const BatchedBridge = require('BatchedBridge');
13+
import {BatchedBridge} from 'react-native/Libraries/ReactPrivate/ReactNativePrivateInterface';
1414

1515
// TODO @sema: Adjust types
16-
import type {ReactNativeType} from 'ReactNativeTypes';
16+
import type {ReactNativeType} from './ReactNativeTypes';
1717

1818
let ReactFabric;
1919

2020
if (__DEV__) {
21-
ReactFabric = require('ReactFabric-dev');
21+
ReactFabric = require('./ReactFabric-dev');
2222
} else {
23-
ReactFabric = require('ReactFabric-prod');
23+
ReactFabric = require('./ReactFabric-prod');
2424
}
2525

2626
BatchedBridge.registerCallableModule('ReactFabric', ReactFabric);

scripts/rollup/shims/react-native/ReactNative.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010

1111
'use strict';
1212

13-
import type {ReactNativeType} from 'ReactNativeTypes';
13+
import type {ReactNativeType} from './ReactNativeTypes';
1414

1515
let ReactNative;
1616

1717
if (__DEV__) {
18-
ReactNative = require('ReactNativeRenderer-dev');
18+
ReactNative = require('./ReactNativeRenderer-dev');
1919
} else {
20-
ReactNative = require('ReactNativeRenderer-prod');
20+
ReactNative = require('./ReactNativeRenderer-prod');
2121
}
2222

2323
module.exports = (ReactNative: ReactNativeType);

scripts/rollup/shims/react-native/createReactNativeComponentClass.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@
1010

1111
'use strict';
1212

13+
import {ReactNativeViewConfigRegistry} from 'react-native/Libraries/ReactPrivate/ReactNativePrivateInterface';
14+
1315
import type {ViewConfigGetter} from './ReactNativeTypes';
1416

15-
const {register} = require('ReactNativeViewConfigRegistry');
17+
const {register} = ReactNativeViewConfigRegistry;
1618

1719
/**
1820
* Creates a renderable ReactNative host component.

0 commit comments

Comments
 (0)