gatsby build fails when StaticQuery has closing tag
See original GitHub issueDescription
When I use <StaticQuery></StaticQuery>
gatsby build
fails.
When I use <StaticQuery />
, everything works.
Failure message:
Error: ./src/components/layout.js
Module build failed (from ./node_modules/babel-loader/lib/index.js):
TypeError: Cannot read property 'push' of undefined
This happens at the following location: https://github.com/gatsbyjs/gatsby/blob/f41eb2a58d8a8d5e84663bb6a9080aa6b3d530df/packages/babel-plugin-remove-graphql-queries/src/index.js#L139
The value of path2.parent is:
Node {
type: 'JSXClosingElement',
start: 1095,
end: 1109,
loc:
SourceLocation {
start: Position { line: 38, column: 8 },
end: Position { line: 38, column: 22 } },
name:
Node {
type: 'JSXIdentifier',
start: 1097,
end: 1108,
loc: SourceLocation { start: [Position], end: [Position] },
name: 'StaticQuery' } }
Environment
System: OS: Linux 4.13 Ubuntu 17.10 (Artful Aardvark) CPU: x64 AMD A10-6700 APU with Radeon™ HD Graphics Shell: 5.2 - /usr/bin/zsh Binaries: Node: 9.10.1 - /usr/local/bin/node Yarn: 1.6.0 - /usr/local/bin/yarn npm: 5.8.0 - /usr/local/bin/npm Browsers: Chrome: 65.0.3325.162 Firefox: 60.0.2 npmPackages: gatsby: next => 2.0.0-beta.9 gatsby-plugin-react-helmet: next => 3.0.0-beta.2 gatsby-plugin-sharp: next => 2.0.0-beta.2 gatsby-plugin-typography: next => 2.2.0-beta.2 gatsby-remark-component: ^1.1.3 => 1.1.3 gatsby-remark-copy-linked-files: next => 2.0.0-beta.2 gatsby-remark-emojis: ^0.2.3 => 0.2.3 gatsby-remark-generic-extensions: ^0.0.1 => 0.0.1 gatsby-remark-images: next => 2.0.1-beta.3 gatsby-remark-smartypants: ^1.4.12 => 1.4.12 gatsby-source-filesystem: next => 2.0.1-beta.3 gatsby-transformer-remark: next => 2.1.1-beta.2
File contents (if changed)
gatsby-config.js
: N/A
package.json
: N/A
gatsby-node.js
: N/A
gatsby-browser.js
: N/A
gatsby-ssr.js
: N/A
Issue Analytics
- State:
- Created 5 years ago
- Comments:20 (17 by maintainers)
No dramas. I did the same a couple of days ago I’m pretty sure. 😄
I may be wrong @deadcoder0904 but I my understanding is that the StaticQuery component receives the data prop so you could remove the data in this line since it doesn’t do anything.
The other components (Helment etc) can only access ‘data’ when they are rendered within StaticQuery because ‘data’ is passed as a prop to StaticQuery not Layout.
Sorry if that is a bad explanation, hopefully it still helps to clarify!