Skip to content
This repository has been archived by the owner on May 26, 2023. It is now read-only.

Using reason-apollo in node.js #154

Open
studious opened this issue Nov 8, 2018 · 6 comments
Open

Using reason-apollo in node.js #154

studious opened this issue Nov 8, 2018 · 6 comments

Comments

@studious
Copy link

studious commented Nov 8, 2018

We use reason-apollo in a mono-repo when developing.

We started with client side ReasonReact code but have now started adding some server side graphql queries. This is breaking due to reason-apollo compiling with import * style notation.

What is the best approach for solving this?

@baransu
Copy link
Contributor

baransu commented Nov 9, 2018

It should depend on your bsconfig.json. If you setup

"package-specs": {
  "module": "commonjs"
}

it should compile to require

@studious
Copy link
Author

studious commented Nov 9, 2018

We are using a mono repo with yarn so our client side and sever side node_modules end up in the same directory when in dev.

Would commonjs work for both?

@emmenko
Copy link
Contributor

emmenko commented Nov 10, 2018

You can make it work for both:

  • compiling to ESM will require that you run your server code through babel to transpile it to CJS
  • compiling to CJS will require that you instruct webpack but you loose e.g. the ability to do tree shaking

I would opt for the first option, to output ESM and to transpile the server side code with babel.

@thangngoc89
Copy link

package-specs actually accepts an array so you can tell bsb to output commonjs and es6 at the same time (but double compilation speed)

@Gregoirevda
Copy link
Contributor

What solution did you pick @studious ?

@studious
Copy link
Author

studious commented Aug 1, 2019

All of our reason applications use commonjs with a webpack/babel step for front end.

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

No branches or pull requests

5 participants