graphql-ppx
graphql-ppx copied to clipboard
inconsistent es6/commonJs in Fragments?
Hi Jaap et al. My coworker points out that the generated code for a fragment file (at least) uses require to bring in @apollo/client but exports using es6 style.. This seems to be a problem for webpack...5? Any tips or plans to square that up? any way I can help?
Thanks Alex
@cid8600 @mattloomis
If you are using template tags we need an inline require(..)
to make it work reliably because ReScript doesn't have support for template tags. You can use templateTagAsFunction
which is documented in rescript-apollo-client
when you use a bundler that doesn't support require
. It's a trade-off, template tags can have some benefits over strings. I would love to have a proper solution for this but I raised possible solutions in the rescript compiler that have not been addressed the past 2 years so I wouldn't hold my breath.
If the require is necessary can the exports be made to be commonjs instead?
im not recalling what a templateTag is
By the way, this shouldn't be a problem with webpack5, I have an webpack 5 website deployed that works fine. What is your configuration?
Hi Jaap
Sorry for the delay...I'm finding this issue again now looking for webpack alternatives.
The build system in question today is vite
(Not a pressing issue, but I would love to never see webpack again, personally)
ahh! templateTagIsFunction! found it