Skip to content

Commit

Permalink
feat(gatsby): remove unused exports from query-engine (#33484)
Browse files Browse the repository at this point in the history
Co-authored-by: gatsbybot <mathews.kyle+gatsbybot@gmail.com>
  • Loading branch information
wardpeet and gatsbybot authored Dec 19, 2021
1 parent 34cb202 commit ccf70da
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/gatsby/src/schema/graphql-engine/print-plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { store } from "../../redux"
import { IGatsbyState } from "../../redux/types"
import { requireGatsbyPlugin } from "../../utils/require-gatsby-plugin"

const schemaCustomizationAPIs = new Set([
export const schemaCustomizationAPIs = new Set([
`setFieldsOnGraphQLNodeType`,
`createSchemaCustomization`,
`createResolvers`,
Expand Down Expand Up @@ -73,7 +73,7 @@ function render(
const imports: Array<string> = [
...uniqGatsbyNode.map(
(plugin, i) =>
`import * as pluginGatsbyNode${i} from "${relativePluginPath(
`import * as pluginGatsbyNode${i} from "gatsby/dist/schema/graphql-engine/webpack-remove-apis-loader!${relativePluginPath(
plugin.resolve
)}/gatsby-node"`
),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { transformSync } from "@babel/core"
import { GatsbyNodeAPI } from "../../redux/types"
import * as nodeApis from "../../utils/api-node-docs"
import { schemaCustomizationAPIs } from "./print-plugins"

module.exports = function loader(source: string): string | null | undefined {
const result = transformSync(source, {
babelrc: false,
configFile: false,
plugins: [
[
require.resolve(`../../utils/babel/babel-plugin-remove-api`),
{
apis: (Object.keys(nodeApis) as Array<GatsbyNodeAPI>).filter(
api => !schemaCustomizationAPIs.has(api)
),
},
],
],
})

return result?.code
}

0 comments on commit ccf70da

Please sign in to comment.