Skip to content

Commit f743c9f

Browse files
committed
fix(babel-plugin-remove-graphql-queries): make sure imports are posix
1 parent c0d6c26 commit f743c9f

File tree

2 files changed

+21
-14
lines changed

2 files changed

+21
-14
lines changed

packages/babel-plugin-remove-graphql-queries/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@
1212
"@babel/cli": "^7.12.1",
1313
"@babel/core": "^7.12.3",
1414
"babel-preset-gatsby-package": "^0.12.0-next.0",
15-
"cross-env": "^7.0.3"
15+
"cross-env": "^7.0.3",
16+
"gatsby-core-utils": "^1.10.0-next.0"
1617
},
1718
"peerDependencies": {
18-
"gatsby": "^2.0.0"
19+
"gatsby": "^2.0.0",
20+
"@babel/core": "^7.0.0"
1921
},
2022
"license": "MIT",
2123
"main": "index.js",

packages/babel-plugin-remove-graphql-queries/src/index.ts

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import graphql from "gatsby/graphql"
44
import { murmurhash } from "./murmur"
55
import nodePath from "path"
66
import { NodePath, PluginObj } from "@babel/core"
7+
import { slash } from "gatsby-core-utils"
78
import { Binding } from "babel__traverse"
89
import {
910
CallExpression,
@@ -300,12 +301,14 @@ export default function ({ types: t }): PluginObj {
300301
const importDeclaration = t.importDeclaration(
301302
[importDefaultSpecifier],
302303
t.stringLiteral(
303-
filename
304-
? nodePath.relative(
305-
nodePath.parse(filename).dir,
306-
resultPath
307-
)
308-
: shortResultPath
304+
slash(
305+
filename
306+
? nodePath.relative(
307+
nodePath.dirname(filename),
308+
resultPath
309+
)
310+
: shortResultPath
311+
)
309312
)
310313
)
311314
path.node.body.unshift(importDeclaration)
@@ -361,12 +364,14 @@ export default function ({ types: t }): PluginObj {
361364
const importDeclaration = t.importDeclaration(
362365
[importDefaultSpecifier],
363366
t.stringLiteral(
364-
filename
365-
? nodePath.relative(
366-
nodePath.parse(filename).dir,
367-
resultPath
368-
)
369-
: shortResultPath
367+
slash(
368+
filename
369+
? nodePath.relative(
370+
nodePath.dirname(filename),
371+
resultPath
372+
)
373+
: shortResultPath
374+
)
370375
)
371376
)
372377
path.node.body.unshift(importDeclaration)

0 commit comments

Comments
 (0)