Despite using the eagerESModules option for the relay-compiler the generated code requires require calls.
The following function is responsible for this: https://github.com/facebook/relay/blob/ba9a3f031f8adc0f60bef603a76385433518cd90/packages/relay-compiler/codegen/createPrintRequireModuleDependency.js
I was able to create a workaround for this within the formatter function inside relay-compiler-language-typescript over here: https://github.com/relay-tools/relay-compiler-language-typescript/pull/269
My specific question is whether this can or should be addressed withing relay-compiler or whether it is better of being inside the language package?
I think this belongs to relay-compiler
https://github.com/relay-tools/relay-compiler-language-typescript/pull/269 feels a bit hacky
It is indeed hacky, the real question is, whether this would be easy to solve within relay-compiler or whether it would require a lot of changes. Also afaik there is a new rust relay-compiler version coming...
Note: The relay-compiler flow formatter implementation prototype for es modules did the exact same: https://github.com/facebook/relay/pull/2841/files#diff-8258e3677c0534bd73d878b16093be514b2227f8972766d881bf903ff5f0e0d9R15-R27
However, the PR got succeeded by https://github.com/facebook/relay/pull/2781, which does not seem to have any logic for adjusting the require calls.
Maybe @TrySound and @vincentriemer could give some input?
When this "require" is added? I have non "requires" in my __generated__ modules.
When using the @refetchable directive on a fragment e.g. https://github.com/dungeon-revealer/dungeon-revealer/blob/069ddd68b23a124f8228a87f6fb5996d3a99d871/src/dm-area/token-info-aside/token-info-side-bar.tsx#L26-L53
Most helpful comment
When using the
@refetchabledirective on a fragment e.g. https://github.com/dungeon-revealer/dungeon-revealer/blob/069ddd68b23a124f8228a87f6fb5996d3a99d871/src/dm-area/token-info-aside/token-info-side-bar.tsx#L26-L53