Skip to content

Commit fea5440

Browse files
committed
Only affect OSS for now
1 parent 8c19b03 commit fea5440

File tree

5 files changed

+28
-87
lines changed

5 files changed

+28
-87
lines changed

packages/react-reconciler/src/__tests__/ReactIsomorphicAct-test.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,16 @@ describe('isomorphic act()', () => {
5050
return text;
5151
}
5252

53-
// @gate !__DEV__
54-
it('is not exported in production builds', () => {
55-
expect(React).not.toHaveProperty('act');
53+
it('behavior in production', () => {
54+
if (!__DEV__) {
55+
if (gate('fb')) {
56+
expect(() => act(() => {})).toThrow(
57+
'act(...) is not supported in production builds of React',
58+
);
59+
} else {
60+
expect(React).not.toHaveProperty('act');
61+
}
62+
}
5663
});
5764

5865
// @gate __DEV__

packages/react-reconciler/src/__tests__/ReactOwnerStacks-test.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,13 @@ describe('ReactOwnerStacks', () => {
3131
);
3232
}
3333

34-
it('is not exported in production buids', () => {
35-
// awkward to gate because FB builds will have it undefined if disabled
36-
// whereas OSS builds will have it stripped if disabled because we only have
37-
// it on in experimental which has a separate entrypoint
34+
it('behavior in production', () => {
3835
if (!__DEV__) {
39-
expect(React).not.toHaveProperty('captureOwnerStack');
36+
if (gate('fb')) {
37+
expect(React).toHaveProperty('captureOwnerStack', undefined);
38+
} else {
39+
expect(React).not.toHaveProperty('captureOwnerStack');
40+
}
4041
}
4142
});
4243

packages/react/index.fb.development.js

Lines changed: 0 additions & 79 deletions
This file was deleted.

packages/react/index.fb.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,12 @@
77
* @flow
88
*/
99

10+
import {enableOwnerStacks} from 'shared/ReactFeatureFlags';
11+
import {captureOwnerStack as captureOwnerStackImpl} from './src/ReactClient';
1012
export {
1113
__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,
1214
__COMPILER_RUNTIME,
15+
act,
1316
cache,
1417
Children,
1518
cloneElement,
@@ -66,3 +69,11 @@ export {useMemoCache as unstable_useMemoCache} from './src/ReactHooks';
6669
// export to match the name of the OSS function typically exported from
6770
// react/compiler-runtime
6871
export {useMemoCache as c} from './src/ReactHooks';
72+
73+
// Only export captureOwnerStack in development.
74+
let captureOwnerStack: ?() => null | string;
75+
if (__DEV__ && enableOwnerStacks) {
76+
captureOwnerStack = captureOwnerStackImpl;
77+
}
78+
79+
export {captureOwnerStack};

scripts/jest/TestFlags.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ function getTestFlags() {
7878
classic: releaseChannel === 'classic',
7979
source: !process.env.IS_BUILD,
8080
www,
81+
fb: www || xplat,
8182

8283
// These aren't flags, just a useful aliases for tests.
8384
enableActivity: releaseChannel === 'experimental' || www || xplat,

0 commit comments

Comments
 (0)