Skip to content

Commit aba9379

Browse files
committed
Paranoia about JSX runtime
1 parent 496a618 commit aba9379

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

scripts/jest/preprocessor.js

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,19 @@ module.exports = {
8080

8181
// This is only for React DevTools tests with React 16.x
8282
// `react/jsx-dev-runtime` and `react/jsx-runtime` are included in the package starting from v17
83-
if (semver.gte(ReactVersionTestingAgainst, '17.0.0')) {
83+
// Technically 16.14 and 15.7 have the new runtime but we're not testing those versions.
84+
if (
85+
semver.gte(ReactVersionTestingAgainst, '15.0.0') &&
86+
semver.lt(ReactVersionTestingAgainst, '17.0.0')
87+
) {
88+
plugins.push(
89+
[
90+
require.resolve('@babel/plugin-transform-react-jsx'),
91+
{runtime: 'classic'},
92+
],
93+
require.resolve('@babel/plugin-transform-react-jsx-source')
94+
);
95+
} else {
8496
plugins.push([
8597
process.env.NODE_ENV === 'development'
8698
? require.resolve('@babel/plugin-transform-react-jsx-development')
@@ -89,14 +101,6 @@ module.exports = {
89101
// would be React.createElement.
90102
{runtime: 'automatic'},
91103
]);
92-
} else {
93-
plugins.push(
94-
[
95-
require.resolve('@babel/plugin-transform-react-jsx'),
96-
{runtime: 'classic'},
97-
],
98-
require.resolve('@babel/plugin-transform-react-jsx-source')
99-
);
100104
}
101105

102106
plugins.push(pathToTransformLazyJSXImport);

0 commit comments

Comments
 (0)