File tree 1 file changed +18
-4
lines changed
packages/gatsby-plugin-typescript/src 1 file changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -21,16 +21,30 @@ function onCreateWebpackConfig({ actions, loaders }) {
21
21
return
22
22
}
23
23
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
+
24
34
actions . setWebpackConfig ( {
25
35
module : {
26
36
rules : [
27
37
{
28
38
test : / \. t s x ? $ / ,
29
39
use : ( { resourceQuery, issuer } ) => [
30
- loaders . js ( {
31
- isPageTemplate : / a s y n c - r e q u i r e s / . test ( issuer ) ,
32
- resourceQuery,
33
- } ) ,
40
+ loaders . js (
41
+ doesUsedGatsbyVersionSupportResourceQuery
42
+ ? {
43
+ isPageTemplate : / a s y n c - r e q u i r e s / . test ( issuer ) ,
44
+ resourceQuery,
45
+ }
46
+ : undefined
47
+ ) ,
34
48
] ,
35
49
} ,
36
50
] ,
You can’t perform that action at this time.
0 commit comments