Skip to content

Commit 150da45

Browse files
authored
fix: dont remove query declaration hash, terser will remove it anyway and it can be useful for 3rd party tools (#20672)
* Remove removal of reference * Update snapshots
1 parent ca3abed commit 150da45

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

packages/babel-plugin-remove-graphql-queries/src/__tests__/__snapshots__/index.js.snap

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ exports[`Allow alternative import of useStaticQuery 1`] = `
55
import React from 'react';
66
import * as Gatsby from 'gatsby';
77
export default (() => {
8+
const query = \\"2626356014\\";
89
const siteTitle = staticQueryData.data;
910
return React.createElement(\\"h1\\", null, siteTitle.site.siteMetadata.title);
1011
});"
@@ -82,7 +83,8 @@ import React from 'react';
8283
export default (() => {
8384
const data = staticQueryData.data;
8485
return React.createElement(React.Fragment, null, React.createElement(\\"h1\\", null, data.site.siteMetadata.title), React.createElement(\\"p\\", null, data.site.siteMetadata.description));
85-
});"
86+
});
87+
export const query = \\"2626356014\\";"
8688
`;
8789

8890
exports[`Transforms only the call expression in useStaticQuery 1`] = `
@@ -103,6 +105,7 @@ exports[`Transforms queries and preserves destructuring in useStaticQuery 1`] =
103105
"import staticQueryData from \\"public/static/d/2626356014.json\\";
104106
import React from 'react';
105107
export default (() => {
108+
const query = \\"2626356014\\";
106109
const {
107110
site
108111
} = staticQueryData.data;
@@ -114,6 +117,7 @@ exports[`Transforms queries and preserves variable type in useStaticQuery 1`] =
114117
"import staticQueryData from \\"public/static/d/2626356014.json\\";
115118
import React from 'react';
116119
export default (() => {
120+
const query = \\"2626356014\\";
117121
let {
118122
site
119123
} = staticQueryData.data;
@@ -137,6 +141,7 @@ exports[`Transforms queries defined in own variable in useStaticQuery 1`] = `
137141
"import staticQueryData from \\"public/static/d/2626356014.json\\";
138142
import React from 'react';
139143
export default (() => {
144+
const query = \\"2626356014\\";
140145
const siteTitle = staticQueryData.data;
141146
return React.createElement(\\"h1\\", null, siteTitle.site.siteMetadata.title);
142147
});"

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -222,11 +222,6 @@ export default function({ types: t }) {
222222
const shortResultPath = `public/static/d/${this.queryHash}.json`
223223
const resultPath = nodePath.join(process.cwd(), shortResultPath)
224224

225-
// Remove query variable since it is useless now
226-
if (this.templatePath.parentPath.isVariableDeclarator()) {
227-
this.templatePath.parentPath.remove()
228-
}
229-
230225
// only remove the import if its like:
231226
// import { useStaticQuery } from 'gatsby'
232227
// but not if its like:

0 commit comments

Comments
 (0)