Closed gaku-sei closed 3 years ago
https://github.com/reasonml-community/rescript-apollo-client/issues/70
Use templateTagIsFunction
for now. To use import we need a functionality in the ReScript compiler to be able to inject the imported gql
(imports cannot be inline).
Currently when setting the template* options as follow:
The PPX will generate something like:
The problem with the above code is that, when the
package-specs/module
option is set toes6
the compiled file will contain a mix of commonjs and es module imports, which some bundlers like Rollup don't really support. Typically, it makes the code raise an exception with Vite.An ideal solution could be to read the
bsconfig.json
file to get the module mode, but it could be complex since it's possible to have several entries in thepackage-specs
setting 😕A temporary option could be to add a
"templateTagModule": "es6" | "commonjs"
option.(The code https://github.com/reasonml-community/graphql-ppx/blob/5d92a6bd8802049141511c809b75087ecd121823/src/bucklescript/output_bucklescript_module.re#L219)