Skip to content

Commit

Permalink
[FB] disable legacy mode in modern build
Browse files Browse the repository at this point in the history
Disables legacy mode in www-modern and removes the entrypoint hack in tests since we gate legacy mode tests now

Additionally disables test utils because this relies on legacy mode.

Additionally gates react-test-renderer test for unstable_Scope because it seems to also rely on legacy roots.
  • Loading branch information
gnoff committed Apr 3, 2024
1 parent 8833338 commit d16d5ca
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions packages/react-dom/src/__tests__/ReactDOMRoot-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ describe('ReactDOMRoot', () => {
expect(container.textContent).toEqual('Hi');
});

// @gate !classic || !__DEV__
// @gate !disableLegacyMode
it('warns if you import createRoot from react-dom', async () => {
expect(() => ReactDOM.createRoot(container)).toErrorDev(
'You are importing createRoot from "react-dom" which is not supported. ' +
Expand All @@ -58,7 +58,7 @@ describe('ReactDOMRoot', () => {
);
});

// @gate !classic || !__DEV__
// @gate !disableLegacyMode
it('warns if you import hydrateRoot from react-dom', async () => {
expect(() => ReactDOM.hydrateRoot(container, null)).toErrorDev(
'You are importing hydrateRoot from "react-dom" which is not supported. ' +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,7 @@ describe('ReactScope', () => {
});

// @gate www
// @gate !disableLegacyMode
it('DO_NOT_USE_queryAllNodes() works as intended', () => {
const testScopeQuery = (type, props) => true;
const TestScope = React.unstable_Scope;
Expand Down Expand Up @@ -430,6 +431,7 @@ describe('ReactScope', () => {
});

// @gate www
// @gate !disableLegacyMode
it('DO_NOT_USE_queryFirstNode() works as intended', () => {
const testScopeQuery = (type, props) => true;
const TestScope = React.unstable_Scope;
Expand Down Expand Up @@ -467,6 +469,7 @@ describe('ReactScope', () => {
});

// @gate www
// @gate !disableLegacyMode
it('containsNode() works as intended', () => {
const TestScope = React.unstable_Scope;
const scopeRef = React.createRef();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,7 @@ describe('ReactSuspense', () => {
});

// @gate forceConcurrentByDefaultForTesting
// @gate !disableLegacyMode
it(
'interrupts current render when something suspends with a ' +
"delay and we've already skipped over a lower priority update in " +
Expand Down
7 changes: 4 additions & 3 deletions packages/shared/forks/ReactFeatureFlags.www.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,10 @@ export const useModernStrictMode = true;
// because JSX is an extremely hot path.
export const disableStringRefs = false;

export const disableLegacyMode = false;

export const disableDOMTestUtils = false;
// These flags need to be on together because disabled legacy mode breaks test utils
// since it is written on top of legacy mode
export const disableLegacyMode = __EXPERIMENTAL__;
export const disableDOMTestUtils = __EXPERIMENTAL__;

// Flow magic to verify the exports of this file match the original version.
((((null: any): ExportsType): FeatureFlagsType): ExportsType);
5 changes: 0 additions & 5 deletions scripts/jest/setupHostConfigs.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ function resolveEntryFork(resolvedEntry, isFBBundle) {
// .js

if (isFBBundle) {
if (__EXPERIMENTAL__) {
// We can't currently use the true modern entry point because too many tests fail.
// TODO: Fix tests to not use ReactDOM.render or gate them. Then we can remove this.
return resolvedEntry;
}
const resolvedFBEntry = resolvedEntry.replace(
'.js',
__EXPERIMENTAL__ ? '.modern.fb.js' : '.classic.fb.js'
Expand Down

0 comments on commit d16d5ca

Please sign in to comment.