babel-plugin-relay 13.0.1 → 13.1.1
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +15 -22
- package/babel-plugin-relay.js +1 -1
- package/babel-plugin-relay.min.js +1 -1
- package/index.js +1 -1
- package/macro.js +1 -1
- package/package.json +6 -2
package/README.md
CHANGED
@@ -1,13 +1,10 @@
|
|
1
|
-
babel-plugin-relay
|
2
|
-
---
|
1
|
+
## babel-plugin-relay
|
3
2
|
|
4
3
|
Relay requires a Babel plugin to convert GraphQL tags to runtime artifacts.
|
5
4
|
|
6
|
-
|
7
|
-
A *very* simplified example of what this plugin is doing:
|
5
|
+
A _very_ simplified example of what this plugin is doing:
|
8
6
|
|
9
7
|
```js
|
10
|
-
|
11
8
|
// It converts this code
|
12
9
|
const fragment = graphql`
|
13
10
|
fragment User_fragment on User {
|
@@ -24,24 +21,20 @@ const fragment = require('__generated__/User_fragment.graphql');
|
|
24
21
|
`babel-plugin-relay` will discover the config if:
|
25
22
|
|
26
23
|
- There is a `relay.config.json`, `relay.config.js` file at the root of the
|
27
|
-
project (i.e. in the same folder as the `package.json` file).
|
24
|
+
project (i.e. in the same folder as the `package.json` file).
|
28
25
|
- The `package.json` file contains a `"relay"` key.
|
29
26
|
|
30
27
|
### Supported configuration options for `babel-plugin-relay`
|
31
28
|
|
32
|
-
- `artifactDirectory`
|
33
|
-
|
34
|
-
|
35
|
-
- `eagerEsModules`
|
36
|
-
|
37
|
-
- `codegenCommand`
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
[string]
|
45
|
-
|
46
|
-
[Configuration Instructions](
|
47
|
-
https://relay.dev/docs/getting-started/installation-and-setup/#set-up-babel-plugin-relay)
|
29
|
+
- `artifactDirectory` A specific directory to output all artifacts to. When
|
30
|
+
enabling this the babel plugin needs `artifactDirectory` to be set as well.
|
31
|
+
[string]
|
32
|
+
- `eagerEsModules` This option enables emitting ES modules artifacts.
|
33
|
+
[boolean][default: false]
|
34
|
+
- `codegenCommand` The command to run to compile Relay files. [string]
|
35
|
+
- `isDevVariableName` Name of the global variable for dev mode (e.g. `__DEV__`).
|
36
|
+
[string]
|
37
|
+
- `jsModuleFormat` Formatting style for generated files. `commonjs` or `haste`.
|
38
|
+
Default is `commonjs`. [string]
|
39
|
+
|
40
|
+
[Configuration Instructions](https://relay.dev/docs/getting-started/installation-and-setup/#set-up-babel-plugin-relay)
|
package/babel-plugin-relay.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
1
|
/**
|
2
|
-
* Relay v13.
|
2
|
+
* Relay v13.1.1
|
3
3
|
*/
|
4
4
|
module.exports=function(e){var r={};function n(t){if(r[t])return r[t].exports;var i=r[t]={i:t,l:!1,exports:{}};return e[t].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=r,n.d=function(e,r,t){n.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,r){if(1&r&&(e=n(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(n.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var i in e)n.d(t,i,function(r){return e[r]}.bind(null,i));return t},n.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(r,"a",r),r},n.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},n.p="",n(n.s=1)}([function(e,r){e.exports=require("graphql")},function(e,r,n){"use strict";var t,i=n(2)(n(3)),o=n(4),a=n(7),s=n(8),l=s("relay",{searchPlaces:["relay.config.js","relay.config.json","package.json"],loaders:{".json":s.loadJson,".js":s.loadJs,noExt:s.loadYaml}}).searchSync();l&&(t=l.config),e.exports=function(e){var r=e.types;if(!r)throw new Error('BabelPluginRelay: Expected plugin context to include "types", but got:'+String(e));var n={TaggedTemplateExpression:function(e,n){var t=a(e);t&&o(r,e,n,t)}};return{visitor:{Program:function(e,r){e.traverse(n,(0,i.default)((0,i.default)({},r),{},{opts:(0,i.default)((0,i.default)({},t),r.opts)}))}}}}},function(e,r){e.exports=require("@babel/runtime/helpers/interopRequireDefault")},function(e,r){e.exports=require("@babel/runtime/helpers/objectSpread2")},function(e,r,n){"use strict";var t=n(5),i=n(0).print,o=n(6),a=o.dirname,s=o.join,l=o.relative,u=o.resolve;e.exports=function(e,r,n,o){var p,d,f,c,g,v,m;if(1!==o.definitions.length)throw new Error("BabelPluginRelay: Expected exactly one definition per graphql tag.");var x=o.definitions[0];if("FragmentDefinition"!==x.kind&&"OperationDefinition"!==x.kind)throw new Error("BabelPluginRelay: Expected a fragment, mutation, query, or subscription, got `"+x.kind+"`.");var h=null!==(p=null===(d=n.opts)||void 0===d?void 0:d.eagerEsModules)&&void 0!==p&&p,b="haste"===(null===(f=n.opts)||void 0===f?void 0:f.jsModuleFormat),y=null===(c=n.opts)||void 0===c?void 0:c.isDevVariableName;return function(e,r,n,o,p){var d=o.name&&o.name.value;if(!d)throw new Error("GraphQL operations and fragments must contain names");var f=d+".graphql",c=p.isHasteMode?f:p.artifactDirectory?function(e,r,n){if(null==e.file)throw new Error("Babel state is missing expected file name");var t=e.file.opts.filename,i=l(a(t),u(r));return(0!==i.length&&i.startsWith(".")?"":"./")+s(i,n)}(r,p.artifactDirectory,f):"./__generated__/"+f,g=t.createHash("md5").update(i(o),"utf8").digest("hex"),v=n.scope;for(;v.parent;)v=v.parent;var m=v.generateUidIdentifier(d),x=e.MemberExpression(m,e.Identifier("hash")),h=function(e,r,n){return e.callExpression(e.memberExpression(e.identifier("console"),e.identifier("error")),[e.stringLiteral("The definition of '".concat(r,"' appears to have changed. Run ")+"`"+n+"` to update the generated files to receive the expected data.")])}(e,d,p.buildCommand),b=e.LogicalExpression("&&",x,e.LogicalExpression("&&",e.BinaryExpression("!==",x,e.StringLiteral(g)),h));if(p.eagerEsModules){var y=e.ImportDeclaration([e.ImportDefaultSpecifier(m)],e.StringLiteral(c));n.findParent((function(e){return e.isProgram()})).unshiftContainer("body",y);var E,q=e.SequenceExpression([b,m]);E=null!=p.isDevVariable?e.ConditionalExpression(e.Identifier(p.isDevVariable),q,m):p.isDevelopment?q:m,n.replaceWith(E)}else{v.push({id:m});var D,w=e.CallExpression(e.Identifier("require"),[e.StringLiteral(c)]),j=e.AssignmentExpression("=",m,w),S=e.SequenceExpression([j,b,m]);D=null!=p.isDevVariable?e.ConditionalExpression(e.Identifier(p.isDevVariable),S,j):p.isDevelopment?S:j;var P=e.UnaryExpression("void",e.NumericLiteral(0));n.replaceWith(e.ConditionalExpression(e.BinaryExpression("!==",m,P),m,D))}}(e,n,r,x,{artifactDirectory:null===(g=n.opts)||void 0===g?void 0:g.artifactDirectory,eagerEsModules:h,buildCommand:null!==(v=null===(m=n.opts)||void 0===m?void 0:m.codegenCommand)&&void 0!==v?v:"relay-compiler",isDevelopment:"production"!==(process.env.BABEL_ENV||"development"),isHasteMode:b,isDevVariable:y})}},function(e,r){e.exports=require("crypto")},function(e,r){e.exports=require("path")},function(e,r,n){"use strict";var t=n(0);e.exports=function(e){if(!e.get("tag").isIdentifier({name:"graphql"}))return null;var r=e.node.quasi.quasis;if(1!==r.length)throw new Error("BabelPluginRelay: Substitutions are not allowed in graphql fragments. Included fragments should be referenced as `...MyModule_propName`.");var n=r[0].value.raw,i=t.parse(n);if(0===i.definitions.length)throw new Error("BabelPluginRelay: Unexpected empty graphql tag.");return i}},function(e,r){e.exports=require("cosmiconfig")}]);
|
package/index.js
CHANGED
package/macro.js
CHANGED
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "babel-plugin-relay",
|
3
3
|
"description": "A Babel Plugin for use with Relay applications.",
|
4
|
-
"version": "13.
|
4
|
+
"version": "13.1.1",
|
5
5
|
"keywords": [
|
6
6
|
"graphql",
|
7
7
|
"relay",
|
@@ -11,7 +11,11 @@
|
|
11
11
|
"license": "MIT",
|
12
12
|
"homepage": "https://relay.dev",
|
13
13
|
"bugs": "https://github.com/facebook/relay/issues",
|
14
|
-
"repository":
|
14
|
+
"repository": {
|
15
|
+
"type": "git",
|
16
|
+
"url": "https://github.com/facebook/relay.git",
|
17
|
+
"directory": "packages/babel-plugin-relay"
|
18
|
+
},
|
15
19
|
"dependencies": {
|
16
20
|
"babel-plugin-macros": "^2.0.0",
|
17
21
|
"cosmiconfig": "^5.0.5",
|