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

Using Reason-Apollo with Create-React-App #95

Closed
1 of 5 tasks
idkjs opened this issue May 24, 2018 · 11 comments
Closed
1 of 5 tasks

Using Reason-Apollo with Create-React-App #95

idkjs opened this issue May 24, 2018 · 11 comments
Labels
has-reproduction ❤ Has a reproduction in a codesandbox or single minimal repository

Comments

@idkjs
Copy link
Contributor

idkjs commented May 24, 2018

Issue Labels

  • has-reproduction
  • feature
  • docs
  • blocking
  • good first issue

I took the examples/swapi demo and tried to run it with create-react-app`.
reproduction
This is the error in browser. Project compiles successfully.
screenshot

Any idea what is going on here?

@ghost ghost added the has-reproduction ❤ Has a reproduction in a codesandbox or single minimal repository label May 24, 2018
@emmenko
Copy link
Contributor

emmenko commented May 24, 2018

Yes, it's because of this bug #80 when you have es6 as output target. Hopefully it will be merged soon 😇

@idkjs
Copy link
Contributor Author

idkjs commented May 25, 2018

I tried the fix locally, getting same error.

@emmenko
Copy link
Contributor

emmenko commented May 25, 2018

Have you clean and rebuild with bsb?

@emmenko
Copy link
Contributor

emmenko commented May 25, 2018

You can try with my branch otherwise (I'm keeping track of the pending fixes).

"reason-apollo": "emmenko/reason-apollo#pending-patches-0.10.0"

@idkjs
Copy link
Contributor Author

idkjs commented May 25, 2018

doesnt work for me. ran clean and rm -rf node_modules lib .merlin reinstalled. Same error. reproduction is updated.

@emmenko
Copy link
Contributor

emmenko commented May 25, 2018

I'll take a look later at the repo then

@Gregoirevda
Copy link
Contributor

@emmenko This isn't the GraphqlTag is not a function error, happening because of the bindings (might not be an issue with the new bs-platform), but parse is not a function.
graphql-tag is using 3 entry points:
main -> bundle
module and next js -> ES6
For some reason, reason-scripts uses ES6 version and there's an error with this import
var parse = require("graphql/language/parse")
require is not defined which leads to an undefined parse

@Gregoirevda
Copy link
Contributor

as references graphql/graphql-js#1248 and facebook/create-react-app#4085

@br1anchen
Copy link

@Gregoirevda did some investigation about CRA(create-react-app) with react-apollo and reason-apollo.
CRA (react-script v1.1.5) works fine with react-apollo(v2.0.4) which requires graphql-tag(v^2.9.2) (graphql).
So I think the problem is how bs-loader loads reason-apollo in this case.
Checked package-specs of reason-apollo:

"package-specs": [
    {
      "module": "es6",
      "in-source": true
    }
  ],

I suspect that's the reason, reason-script uses ES6 module for reason-apollo.
However, bs-loader recommends
using bsb in-source builds, so by set inSource: true as default bs-loader options in reason-script seems fixing the problem.
I made PR for it, even though reason-script will not be actively maintained.
Feel free to fork/tag my forked repo in your package.json to try out.

@Gregoirevda
Copy link
Contributor

Thanks @br1anchen! As you said reason-scripts won't be supported anymore and he recommends switching to parcel rrdelaney/reason-scripts#69 (comment)
I'll make an example of that

@idkjs
Copy link
Contributor Author

idkjs commented Sep 20, 2018

@Gregoirevda any demo of the parcel bsb with reason-apollo? I will take a shot at the example with a head start maybe.

@idkjs idkjs closed this as completed Sep 20, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
has-reproduction ❤ Has a reproduction in a codesandbox or single minimal repository
Projects
None yet
Development

No branches or pull requests

4 participants