Relay: Rust compiler: purging non-Relay files from __generated__ folders

Created on 2 Apr 2021  Â·  2Comments  Â·  Source: facebook/relay

Hi, I have a feature request (or proposal/discussion) for the new Rust compiler. I noticed that the new compiler always deletes the whole content of __generated__ folder. It's even explained here: https://github.com/facebook/relay/blob/63c4e99687c26a9e05b42e6e68aa55782a45a135/compiler/crates/relay-compiler/src/config.rs#L667-L672

I see the __generated__ folder to be a nice convention together with __tests__, __fixtures__ and so on. Nothing screams from it "Relay" (but rather "it's generated content"). So I used this pattern for some other use-cases where I generate some kind of non-Relay content into __generated__. This obviously brings some troubles now since Relay Rust compiler purges these files (even though it has nothing to do with Relay and there are no Relay artifacts).

What is the recommended strategy here? Or perhaps, would you please reconsider this behavior? Some other solutions could be:

  • target only *.graphql.js (or new *.relay.js) files under __generated__/…
  • have the possibility to put Relay artifacts under __generated__/relay/…
  • have the possibility to keep subfolders like __generated__/something-different/…

Have you encountered this situation inside Facebook? How did you solve it?

Thanks! 😎

bug rust

All 2 comments

For most code we use a fixed output directory, but in the places we use the relative directory I don't think we had anything other then Relay in them.

I think it'd be reasonable to match on *.graphql.js or *.graphql.ts.

Not sure I feel good about adding yet another output directory version as our options are already kindof hard to all test and it'd also add more confusion to the config as it would also need that configuration in the Babel plugin, I think.

But assuming the existing JS compiler only removes the Relay files, we should fix this.

Was this page helpful?
0 / 5 - 0 ratings