Closed n1ru4l closed 3 years ago
Hi @n1ru4l, thanks for your PR, I didn't add the module in the package because I was waiting for help to verify ESM support 💯
In this PR https://github.com/relay-tools/relay-hooks/pull/162 I have added the tests for useMutation so that I can better verify this PR :)
After digging more, for Node.js to be compatible the file extension of the modules must be .mjs
and all the imports must specify the .mjs
extension. See https://github.com/enisdenjo/graphql-ws/pull/110/files
Since React does not ship ESM modules Node.js support does not matter that much, however, this library will hopefully not require any more changes when react starts shipping esm modules :)
hi @n1ru4l, can you update the PR with the master and fix the warnings?
@morrys done :)
@n1ru4l I tried the bundle in the example projects cra and pagination-nextjs-ssr and I get errors similar to this: https://github.com/facebook/create-react-app/issues/10356
@morrys Seems like create-react-app is not properly configured to support the .mjs
extension.
An alternative approach (that could potentially break the common js module) could be the following: https://unpkg.com/browse/@tinyhttp/app@1.1.12/package.json
"type": "module",
This tells Node.js that any .js
file should be treated as if it is was a .mjs
file.
I found this and will try it: https://github.com/d3/d3/issues/3469#issue-809713670
When will this be merged?
For now it is not merged because there are problems https://github.com/relay-tools/relay-hooks/pull/161#issuecomment-779247359
i now have a solution that works consistently. I will try to update the PR this week :)
I noticed that the esm version was broken due to @restart/hooks not being esm compatible and the es module export entry in the package.json missing.
I removed the @restart/hooks dependency in favor of a simply inline of the logic and also adjusted the package.json for the es export.
With those changes, relay-hooks can be successfully used with snowpack.