Skip to content

Commit 564a8f7

Browse files
marvinjudepieh
andauthored
fix(gatsby-plugin-typescript): only use resourceQuery for supported version of gatsby (#36328)
Co-authored-by: Michal Piechowiak <[email protected]>
1 parent db4dc09 commit 564a8f7

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

packages/gatsby-plugin-typescript/src/gatsby-node.js

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,30 @@ function onCreateWebpackConfig({ actions, loaders }) {
2121
return
2222
}
2323

24+
let doesUsedGatsbyVersionSupportResourceQuery
25+
try {
26+
const { version } = require(`gatsby/package.json`)
27+
const [major, minor] = version.split(`.`).map(Number)
28+
doesUsedGatsbyVersionSupportResourceQuery =
29+
(major === 4 && minor >= 19) || major > 4
30+
} catch {
31+
doesUsedGatsbyVersionSupportResourceQuery = true
32+
}
33+
2434
actions.setWebpackConfig({
2535
module: {
2636
rules: [
2737
{
2838
test: /\.tsx?$/,
2939
use: ({ resourceQuery, issuer }) => [
30-
loaders.js({
31-
isPageTemplate: /async-requires/.test(issuer),
32-
resourceQuery,
33-
}),
40+
loaders.js(
41+
doesUsedGatsbyVersionSupportResourceQuery
42+
? {
43+
isPageTemplate: /async-requires/.test(issuer),
44+
resourceQuery,
45+
}
46+
: undefined
47+
),
3448
],
3549
},
3650
],

0 commit comments

Comments
 (0)