Open arcticmatt opened 2 years ago
@arcticmatt it just ignores __generated__
by default. You can add your own exclude
to the config without it.
This seems problematic over time, relay-compiler-language-typescript which is now obsolete, since Relay 13, did this clean up automatically
Actually what @ch1ffa said works very well. If you change the relay config to something like
{
...
"exclude": [
"**/node_modules/**",
"**/mocks/**"
]
}
the "unneeded" files are automatically deleted by the relay compiler which is pretty neat.
Why the default behaviour in Relay is collecting stale generated files? I think it would be better if one of the things will happen:
**/__generated__/**
directory will be removed from the exclude
config, but it's not the best solution because in this case relay will try to find fragments there and waste time for it.exclude
config. I think it's much better. exclude
only means "don't try to find fragments here and there", it shouldn't be about ignoring stale files that was generated by relay. It's strange behaviour. I think it's important to remove all stale generated files by default, because types from there can be used by components (if the TypeScript is used). So if the stale generated files are not deleted, it means that some components may use already stale types that can lead to bugs.
Thus I think the stale generated files must be removed by relay by default in spite of this directory is specified in the exclude
config.
Additionally, trying to remove all generated files prior to running the relay compiler causes many dev tools, like the WebPack dev server or WebStorm's indexation, to go completely out wack and think the files don't exist even if relay regenerates them.
This means that I have to choose between stale definitions, which means a risk of commiting invalid code, or a broken hot reload on a project where the dev server takes 3 minutes to start due to the size...
The only way to prevent this problem, is for the relay compiler to delete only stale files.
For example, let's say I have
Foo.tsx
, which contains a GraphQL mutation calledFooMutation
. This will cause Relay compiler to generate a file calledFooMutation.graphql.ts
However, if I delete
FooMutation
fromFoo.tsx
, and then re-run the Relay compiler,FooMutation.graphql.ts
will still be there. I expected it to be deleted