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

inconsistent es6/commonJs in Fragments? #271

Open
AlexMoutonNoble opened this issue Sep 13, 2021 · 7 comments
Open

inconsistent es6/commonJs in Fragments? #271

AlexMoutonNoble opened this issue Sep 13, 2021 · 7 comments

Comments

@AlexMoutonNoble
Copy link

AlexMoutonNoble commented Sep 13, 2021

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

@jfrolich
Copy link
Collaborator

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.

@AlexMoutonNoble
Copy link
Author

If the require is necessary can the exports be made to be commonjs instead?

@AlexMoutonNoble
Copy link
Author

im not recalling what a templateTag is

@jfrolich
Copy link
Collaborator

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?

@AlexMoutonNoble
Copy link
Author

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

@AlexMoutonNoble
Copy link
Author

(Not a pressing issue, but I would love to never see webpack again, personally)

@AlexMoutonNoble
Copy link
Author

ahh! templateTagIsFunction! found it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants