code generator should not generate empty global-types
continuation of https://github.com/apollographql/apollo-tooling/issues/1179#issuecomment-616496523
Intended outcome:
global-types.ts cannot be empty as this breaks typescript compiler when --isolatedModules is set. This option can not be disabled for nextjs users
Actual outcome:
if there is nothing to put into global-types.ts, apollo generates an empty file. This throws an error on build Type error: All files must be modules when the '--isolatedModules' flag is provided.
How to reproduce the issue:
set isolatedModules and run a build
Versions
apollo 2.28.3
a workaround to that would be to just exclude it in tsconfig.json
"exclude": ["./src/__generated__/globalTypes.ts"]
I also had the same problem. Seems like the only way for now is to exclude globalTypes in tsconfig.json
This is also a problem in Create React App.
Excluding the file is not a great workaround, as the exclusion must be removed once there are contents in the file.
CRA suggests adding export {} to trick the compiler into treating it as a module. That seems like a pretty bad hack. I agree that it would be better not to write the file when it's empty.
I opened #2163 to fix this.
really guys, can we PLEASE get this fixed? This is a complete unnecessary problem thats wasting everybody's time.
@hwillson anyone, please, we beg you. We know it has no longer priority for you, but its really small problem to fix and would help so many people.
@macrozone I'll take a look!
@macrozone I'll take a look!
thank you, sorry for bragging. 😳
see also https://github.com/apollographql/apollo-tooling/pull/2163
Whoa, blast from the past! I ran into this issue again today, and realized #2163 hasn't been merged. @hwillson I just updated the PR and the tests are passing now. Could I ask you to please take a look?