d4rekanguok/gatsby-typescript

codegen is extremely slow after upgrading from gatsby 2.24.11 to 2.24.12

Opened this issue · 1 comments

I am not quire sure what's changed between these two versions. Nothing stands out, but after upgrading to 2.24.12, my build time went through the roof.

Before:
run page queries - 1.823s - 43/43 23.58/s

After:
run page queries - 59.584s - 145/145 2.43/s

Removing gatsby-plugin-graphql-codegen fixes the issue. It appears the slowness is coming from createConfig. generateWithConfig is called twice during a gatsby develop once during onPostBootstrap and again right during the page queries. Whatever it is doing it is causing the whole build step to halt. This only seems to affect develop builds and not production.

To Reproduce
run gatsby develop on a repository with many page queries on gatsby 2.24.12 or newer (haven't tested 3.0).

Environment (please complete the relevant info):

  • OS: OSX
  • Gatsby Version: 2.25.1 (confirmed it started at 2.24.12)
  • Typescript version: 3.97

Additional context

    {
      resolve: `gatsby-plugin-graphql-codegen`,
      options: {
        codegenConfig: {
          maybeValue: 'T | undefined',
        },
      },
    },

We do use gatsby-sanity-source, but unsure if that is affecting the scenario. It only started with a new version of gatsby.

Looks like I was able to get this fixed by setting the following documentPaths:

        documentPaths: [
          './src/**/*.{ts,tsx}',
          './node_modules/gatsby-source-sanity/fragments/*.js',
        ],

Related #93