-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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
babel-preset-react-app: add babel-plugin-relay #2343
Conversation
Adds support for Relay Modern. relay-compiler, relay-runtime, and react-relay are all "peer" dependencies, including the script to run relay compiler. This at least unblocks CRA from being able to develop Relay Modern. https://facebook.github.io/relay/docs/babel-plugin-relay.html https://facebook.github.io/relay/docs/relay-compiler.html
Hmm. This doesn't look complicated. Any caveats? |
Caveats.
I have tested this by directly adding this change within my |
Does it break any other graphql solutions, like Apollo? |
Can we make a PR to Babel plugin to enforce import/require name? |
It looks like the plugin and runtime are designed to be used verbatim, so I'm not sure if that would be an option. |
What about reading package.json and looking for packages like relay-compiler and react-relay in order to use this plugin? No wasted cycles, no need to worry about Apollo (I think) |
I don't see an issue for this on the Relay repo and apparently package detection is non-trivial; is there a plan to move forward with this? |
I hope so. Is CRA doing package detection anywhere else at the moment? I would have preferred to keep this as a one line ish change. |
There is |
We need some plan for a bunch of optional dependencies people want: Sass, Relay, TypeScript. These are all in principle possible to support but we don't want to either create a second plugin system (which webpack already "is") nor to increase default download size. If you figure out a creative way out of this problem I'd love to know! |
This should probably be merged without that system. It's pretty innocuous. |
Ping @gaearon |
I'm not sure whether I've just done something stupid, but attempting to apply the same monkey-patch to my own copy of the Would definitely like to see proper relay modern support in CRA, the majority of the reason I went with CRA was because I thought it would save me from all this. |
Hello! I'm a bot that helps facilitate testing pull requests. Your pull request (commit 56d72ae) has been released on npm for testing purposes. npm i [email protected]
# or
yarn add [email protected]
# or
create-react-app [email protected] folder/ Note that the package has not been reviewed or vetted by the maintainers. Only install it at your own risk! Thanks for your contribution! |
I get the following error after creating a new react app, running I don't know if it's somehow related, but it seems that exactly the same error happened in another pull request introducing different feature: #2714 |
Any update on this? |
Since #3909 has landed, I believe this change – i.e. simply adding |
With the next Relay release (after 1.6.2) and 2.0 of react-scripts, you'll be able to do
I don't think there needs to be a direct dependency? |
Thanks @kassens that's great news! Is there any ETA on the Relay release? Or even a days/weeks/months estimate? |
Closing per #2343 (comment). |
@shaneosullivan let me try to do an RC this week, so we can test this easily! |
Awesome, thanks @kassens! Some additional updates to docs and examples would be a huge help too, the current ones on master are fairly confusing |
Is there anything we can help to speed this up? testing or writing documentation... I have been searching for it for long time |
Example of RC usage (expanding from @kassens comments from Aug 14, his example repo): (For anyone else finding this thread and wanting an example.) |
Adds support for Relay Modern. relay-compiler, relay-runtime, and
react-relay are all "peer" dependencies, including the script to run
relay compiler. This at least unblocks CRA from being able to develop
Relay Modern.
https://facebook.github.io/relay/docs/babel-plugin-relay.html
https://facebook.github.io/relay/docs/relay-compiler.html
#2001 (comment)
Because Relay Modern does not require a schema for babel, this makes the integration process so much easier. Hopefully we can get this merged, but if you think it would be blocked by needing documentation, let me know what a general idea of what you're looking for and we can get that added as well.