Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(gatsby): remove unused exports from query-engine #33484

Merged
merged 5 commits into from
Dec 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}