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

Document the use of babel-relay-plugin with React Native #935

Closed
steveluscher opened this issue Mar 10, 2016 · 13 comments
Closed

Document the use of babel-relay-plugin with React Native #935

steveluscher opened this issue Mar 10, 2016 · 13 comments

Comments

@steveluscher
Copy link
Contributor

Can someone add a little note to the docs that explains how and why to configure the babel-relay-plugin to run before the react-native Babel preset?

{
  "passPerPreset": true,
  "presets": [
    {"plugins": ["./plugins/babelRelayPlugin"]},
    "react-native"
  ]
}
@steveluscher
Copy link
Contributor Author

Further reading: #714.

@vjefri
Copy link
Contributor

vjefri commented Mar 10, 2016

I can read over #714 and add a paragraph that explains why we need to configure the babel-relay-plugin to run before the react-native. Modifications should be made here correct: https://facebook.github.io/relay/docs/guides-babel-plugin.html#content? Thanks again.

@steveluscher
Copy link
Contributor Author

That sounds like a good place. Thanks!

On Mar 10, 2016, at 8:36 AM, Jefri Vanegas notifications@github.com wrote:

I can read over #714 #714 and add a paragraph that explains why we need to configure the babel-relay-plugin to run before the react-native. Modifications should be made here correct: https://facebook.github.io/relay/docs/guides-babel-plugin.html#content https://facebook.github.io/relay/docs/guides-babel-plugin.html#content? Thanks again.


Reply to this email directly or view it on GitHub #935 (comment).

ghost pushed a commit that referenced this issue Apr 14, 2016
Summary:This adds a paragraph here, https://facebook.github.io/relay/docs/guides-babel-plugin.html#content, under Usage describing how to configure the babel-relay-plugin with React Native. Fixes issue #935.
Closes #941

Differential Revision: D3179444

Pulled By: josephsavona

fb-gh-sync-id: 22bb274b1618d437d476c9d5217c8695c902c13c
fbshipit-source-id: 22bb274b1618d437d476c9d5217c8695c902c13c
@abhishiv
Copy link

abhishiv commented Jun 2, 2016

Hey guys, is this broken for anyone else on 0.9? I'm getting Unexpected invocation at runtimer error, and have been trying to track it down all day today.

@steveluscher
Copy link
Contributor Author

Hey @abhishiv! Post a question on Stack Overflow with the tag #relayjs with as much detail as you possibly can about your setup. Be sure to post a link back here so we can follow up.

@abhishiv
Copy link

abhishiv commented Jun 3, 2016

Thanks Steve, I was finally able to track it down. It seems to be a very strange issue. I'll just leave the resolution in this thread in case someone else gets stuck like me.

@BerndWessels/babel-relay-plugin-loader

https://stackoverflow.com/questions/37449580/this-is-no-longer-bound-when-using-arrow-functions-after-upgrading-to-react-nati/37474298#37474298

@gre
Copy link

gre commented Jun 19, 2016

This configuration does not seem to work as soon as your code or one of your lib use the class property method of ES2015.

I mean this:

class A {
  bar () { return "it works!"; }
  foo = () => this.bar();
}
new A().foo();

it breaks with the config mentioned above.

Why not just:

{
  "presets": ["react-native"],
  "plugins": [
    "./plugins/babelRelayPlugin"
  ]
}

^^^ This seems to work and don't have the issue i'm mentionning.

( context gre/gl-react-native-v2#90 (comment) )

@chirag04
Copy link

chirag04 commented Jul 7, 2016

@gre class properties after babel-core 6.5 does not work with passPerPreset.(https://phabricator.babeljs.io/T7274)

@steveluscher wondering if passPerPreset is required now.

@st0ffern
Copy link

st0ffern commented Jul 7, 2016

@chirag04 been using this solution for quite a while, and it works fine for me

@alloy
Copy link
Contributor

alloy commented Jul 7, 2016

My working setup is the same as @gre’s.

@taion
Copy link
Contributor

taion commented Aug 4, 2016

BTW, digging into this a bit –

The order in which plugins run is actually:

  1. All plugins in order
  2. All presets in reverse order

This means that if you apply the template literal transform in a preset, then as long as you specify the Relay transform in plugins, or you specify the preset with the Relay transform after the preset with the template literal transform, then you don't need passPerPreset.

@taion
Copy link
Contributor

taion commented Aug 4, 2016

BTW, I would suggest recommending against the use of passPerPreset. Various things tend to go wrong when using passPerPreset, such that it feels cleaner to just make sure the Relay Babel plugin gets listed in the correct place.

@wincent
Copy link
Contributor

wincent commented Jan 30, 2017

(Spring cleaning.) This issue was created nearly a year ago and is now quite stale. Going to close it out, but please feel free to submit any improvements to the documentation as PRs; we're always happy to see the documentation get better.

@wincent wincent closed this as completed Jan 30, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants