File tree 1 file changed +8
-1
lines changed
packages/gatsby/src/utils
1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ import MiniCssExtractPlugin from "mini-css-extract-plugin"
9
9
import OptimizeCssAssetsPlugin from "optimize-css-assets-webpack-plugin"
10
10
import ReactRefreshWebpackPlugin from "@pmmmwh/react-refresh-webpack-plugin"
11
11
import { getBrowsersList } from "./browserslist"
12
+ import semver from "semver"
12
13
13
14
import { GatsbyWebpackStatsExtractor } from "./gatsby-webpack-stats-extractor"
14
15
import { GatsbyWebpackEslintGraphqlSchemaReload } from "./gatsby-webpack-eslint-graphql-schema-reload-plugin"
@@ -721,7 +722,13 @@ function reactHasJsxRuntime(): boolean {
721
722
// Not every version of React has this jsx-runtime yet. Eventually,
722
723
// it will be backported to older versions of react and this check
723
724
// will become unnecessary.
724
- return ! ! require . resolve ( `react/jsx-runtime.js` )
725
+
726
+ // for now we also do the semver check until react 17 is more widely used
727
+ const react = require ( `react/package.json` )
728
+ return (
729
+ ! ! require . resolve ( `react/jsx-runtime.js` ) &&
730
+ semver . major ( react . version ) >= 17
731
+ )
725
732
} catch ( e ) {
726
733
// If the require.resolve throws, that means this version of React
727
734
// does not support the jsx runtime.
You can’t perform that action at this time.
0 commit comments