cometkim / gatsby-plugin-typegen

Let's give developers using GatsbyJS better DX with extreme type-safety
https://www.gatsbyjs.org/packages/gatsby-plugin-typegen/
MIT License
204 stars 25 forks source link

How to run as part of pre script? #173

Closed stretch0 closed 2 years ago

stretch0 commented 2 years ago

Is it possible to run this plugin as part of a pre script?

Types get generated when developing which is fine but would good to then gitignore them and have them generated when a build happens.

This mans when the next developer pulls down the code changes, the app wont run because it can't start with missing types / interfaces.

Running a codegen in a pre start script of some description would solve this. Is this possible?

cometkim commented 2 years ago

No. Because this plugin is deeply dependent on the GatsbyJS process, it cannot currently be run independently.

Since v3, It may provide a feature flag to kill the gatsby process immediately after emmitting files.

stretch0 commented 2 years ago

Does that mean __generated__/gatsby-types.ts can't be gitignored?

cometkim commented 2 years ago

... If you want type-check first. I guess so.

stretch0 commented 2 years ago

Actually, nvm. Just realised it's because we were running our tsc command before the app had started

"start": "tsc && gatsby develop",

Have moved tsc to poststart script now

"start": "gatsby develop",
"poststart": "tsc",
cometkim commented 2 years ago

Hmm well, Just sayin fyi

Since types in GatsbyJS are inferred after the query compiler is executed, there is no way to check it completely before that process done at least once.