Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v13] relay-compiler generates require calls instead of top-level imports when eagerEsModules #3726

Closed
Tracked by #3749
asterikx opened this issue Jan 7, 2022 · 10 comments
Labels
bug fixready rust Related to the compiler written in Rust

Comments

@asterikx
Copy link

asterikx commented Jan 7, 2022

The generated files include require calls even when I specify eagerEsModules: true (previously eagerESModules) in relay.config.js file.
In relay@12.0.0, relay-compiler-language-typescript@15.0.0 generates top-level import statements instead of require calls if I specify eagerESModules : true. In relay@13.0.0, this is no longer true.
This prevents use with modern frontend tools, e.g. Vite, which do not transform require calls: Uncaught ReferenceError: require is not defined.

@alunyov
Copy link
Contributor

alunyov commented Jan 7, 2022

Hey @asterikx do you have an example repro? Or can you add an example of the generated file with the require call?

@TrySound
Copy link
Contributor

TrySound commented Jan 7, 2022

This is probably related to babel-plugin-relay rather than compiler
#3724

@TrySound
Copy link
Contributor

TrySound commented Jan 7, 2022

The workaround is to add eagerESModules option in babel config

@alunyov
Copy link
Contributor

alunyov commented Jan 7, 2022

The workaround is to add eagerESModules option in babel config

The 13.0.1 with your fix is coming soon.

@asterikx
Copy link
Author

asterikx commented Jan 7, 2022

No it's not babel-plugin-relay's fault. babel-plugin-relay only replaces the query strings in the files by the concrete requests. eagerESModules will only change the import style for that replacement. The imported file (the concrete request) still contains require calls (mostly on pagination fields I think). I will link a repo here in a few minutes.

@TrySound
Copy link
Contributor

TrySound commented Jan 7, 2022

mostly on pagination fields I think

This is probably came from old tests where refetchable was implemented only for commonjs.

@tessro
Copy link

tessro commented Jan 29, 2022

We are still seeing this in v13.0.1, with pagination only.

@tessro
Copy link

tessro commented Jan 29, 2022

Actually, this appears to happen specifically with @refetchable. The query named as queryName is always required.

@tessro
Copy link

tessro commented Jan 29, 2022

Ignore me, this is fixed in v13.0.2! 🙃

8ac91d7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug fixready rust Related to the compiler written in Rust
Projects
None yet
Development

No branches or pull requests

4 participants