Skip to content

Commit 49e68a0

Browse files
committed
Break up require/import statements in strings
1 parent 6a0efdd commit 49e68a0

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

packages/react-reconciler/src/ReactFiberWorkLoop.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2863,11 +2863,15 @@ export function warnIfNotScopedWithMatchingAct(fiber: Fiber): void {
28632863
"It looks like you're using the wrong act() around your test interactions.\n" +
28642864
'Be sure to use the matching version of act() corresponding to your renderer:\n\n' +
28652865
'// for react-dom:\n' +
2866-
"import {act} from 'react-dom/test-utils';\n" +
2866+
// Break up imports to avoid accidentally parsing them as dependencies.
2867+
'import {act} fr' +
2868+
"om 'react-dom/test-utils';\n" +
28672869
'// ...\n' +
28682870
'act(() => ...);\n\n' +
28692871
'// for react-test-renderer:\n' +
2870-
"import TestRenderer from 'react-test-renderer';\n" +
2872+
// Break up imports to avoid accidentally parsing them as dependencies.
2873+
'import TestRenderer fr' +
2874+
"om react-test-renderer';\n" +
28712875
'const {act} = TestRenderer;\n' +
28722876
'// ...\n' +
28732877
'act(() => ...);' +
@@ -2953,7 +2957,9 @@ export function warnIfUnmockedScheduler(fiber: Fiber) {
29532957
'In Concurrent or Sync modes, the "scheduler" module needs to be mocked ' +
29542958
'to guarantee consistent behaviour across tests and browsers. ' +
29552959
'For example, with jest: \n' +
2956-
"jest.mock('scheduler', () => require('scheduler/unstable_mock'));\n\n" +
2960+
// Break up requires to avoid accidentally parsing them as dependencies.
2961+
"jest.mock('scheduler', () => require" +
2962+
"('scheduler/unstable_mock'));\n\n" +
29572963
'For more info, visit https://fb.me/react-mock-scheduler',
29582964
);
29592965
} else if (warnAboutUnmockedScheduler === true) {
@@ -2962,7 +2968,9 @@ export function warnIfUnmockedScheduler(fiber: Fiber) {
29622968
'Starting from React v17, the "scheduler" module will need to be mocked ' +
29632969
'to guarantee consistent behaviour across tests and browsers. ' +
29642970
'For example, with jest: \n' +
2965-
"jest.mock('scheduler', () => require('scheduler/unstable_mock'));\n\n" +
2971+
// Break up requires to avoid accidentally parsing them as dependencies.
2972+
"jest.mock('scheduler', () => require" +
2973+
"('scheduler/unstable_mock'));\n\n" +
29662974
'For more info, visit https://fb.me/react-mock-scheduler',
29672975
);
29682976
}

packages/shared/ReactLazyComponent.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ export function initializeLazyComponentType(
5050
console.error(
5151
'lazy: Expected the result of a dynamic import() call. ' +
5252
'Instead received: %s\n\nYour code should look like: \n ' +
53-
"const MyComponent = lazy(() => import('./MyComponent'))",
53+
// Break up imports to avoid accidentally parsing them as dependencies.
54+
'const MyComponent = lazy(() => imp' +
55+
"ort('./MyComponent'))",
5456
moduleObject,
5557
);
5658
}

0 commit comments

Comments
 (0)