You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Summary:
This PR adds support for [babel-plugin-macros](https://github.com/kentcdodds/babel-plugin-macros).
Usage:
```js
import graphql from 'babel-plugin-relay/macro';
// Or:
// const graphql = require('babel-plugin-relay/macro');
```
`graphql` is exported from both the `react-relay` and `relay-runtime` packages, but as I created this PR mostly in the interest of possible Create React App integration, I only added an export to `react-relay`.
This PR currently only adds support for Relay Modern. I'm not sure if Compat and/or Classic should be supported?
I currently only have a single basic test. I certainly could copy over the fixtures in `__tests__/fixtures-modern` and change the imports, although I'm not sure how beneficial that would be, as most of the logic is shared with `babel-plugin-relay`.
Closes#1968
Related: facebook/create-react-app#2730 (comment)
/cc kentcdodds
Pull Request resolved: #2171
Reviewed By: jstejada
Differential Revision: D6831205
Pulled By: kassens
fbshipit-source-id: 704a239b45974359cc1dcecacd85efb4aeddeef5
Copy file name to clipboardExpand all lines: docs/Introduction-InstallationAndSetup.md
+6Lines changed: 6 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -35,6 +35,12 @@ Babel's [documentation on this topic](https://babeljs.io/docs/plugins/#pluginpre
35
35
36
36
See the [Migration Setup](./migration-setup.html) guide if upgrading an existing Relay app.
37
37
38
+
Alternatively, instead of using `babel-plugin-relay`, you can use Relay with [babel-plugin-macros](https://github.com/kentcdodds/babel-plugin-macros). After installing `babel-plugin-macros` and adding it to your Babel config:
39
+
40
+
```javascript
41
+
constgraphql=require('babel-plugin-relay/macro');
42
+
```
43
+
38
44
## Set up relay-compiler
39
45
40
46
Relay's ahead-of-time compilation requires the [Relay Compiler](./graphql-in-relay.html#relay-compiler.html), which you can install via `yarn` or `npm`:
0 commit comments