babel-plugin-relay 13.0.0-rc.1 → 13.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -31,14 +31,17 @@ if (result) {
31
31
 
32
32
  export type RelayPluginOptions = {
33
33
  // The command to run to compile Relay files, used for error messages.
34
- buildCommand?: string,
35
- // Use haste style global requires, defaults to false.
36
- haste?: boolean,
37
- // Check this global variable before validation.
38
- isDevVariable?: string,
34
+ codegenCommand?: string,
35
+
36
+ // Formatting style for generated files. `commonjs` or `haste`.
37
+ // Default is `commonjs`.
38
+ jsModuleFormat?: string,
39
+
40
+ // Name of the global variable for dev mode
41
+ isDevVariableName?: string,
39
42
 
40
43
  // enable generating eager es modules for modern runtime
41
- eagerESModules?: boolean,
44
+ eagerEsModules?: boolean,
42
45
 
43
46
  // Directory as specified by artifactDirectory when running relay-compiler
44
47
  artifactDirectory?: string,
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) Facebook, Inc. and its affiliates.
3
+ Copyright (c) Meta Platforms, Inc. and affiliates.
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md ADDED
@@ -0,0 +1,40 @@
1
+ ## babel-plugin-relay
2
+
3
+ Relay requires a Babel plugin to convert GraphQL tags to runtime artifacts.
4
+
5
+ A _very_ simplified example of what this plugin is doing:
6
+
7
+ ```js
8
+ // It converts this code
9
+ const fragment = graphql`
10
+ fragment User_fragment on User {
11
+ name
12
+ }
13
+ `;
14
+
15
+ // To require generated ASTs for fragments and queries
16
+ const fragment = require('__generated__/User_fragment.graphql');
17
+ ```
18
+
19
+ ## Plugin Configuration
20
+
21
+ `babel-plugin-relay` will discover the config if:
22
+
23
+ - There is a `relay.config.json`, `relay.config.js` file at the root of the
24
+ project (i.e. in the same folder as the `package.json` file).
25
+ - The `package.json` file contains a `"relay"` key.
26
+
27
+ ### Supported configuration options for `babel-plugin-relay`
28
+
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)
@@ -1,4 +1,4 @@
1
1
  /**
2
- * Relay v13.0.0-rc.1
2
+ * Relay v13.0.2
3
3
  */
4
- module.exports=function(e){var r={};function t(n){if(r[n])return r[n].exports;var i=r[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,t),i.l=!0,i.exports}return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:n})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,r){if(1&r&&(e=t(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var i in e)t.d(n,i,function(r){return e[r]}.bind(null,i));return n},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},t.p="",t(t.s=1)}([function(e,r){e.exports=require("graphql")},function(e,r,t){"use strict";var n,i=t(2)(t(3)),o=t(4),a=t(7),s=t(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&&(n=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 t={TaggedTemplateExpression:function(e,t){var n=a(e);n&&o(r,e,t,n)}};return{visitor:{Program:function(e,r){e.traverse(t,(0,i.default)((0,i.default)({},r),{},{opts:(0,i.default)((0,i.default)({},n),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,t){"use strict";var n=t(5),i=t(0).print,o=t(6),a=o.dirname,s=o.join,l=o.relative,u=o.resolve;e.exports=function(e,r,t,o){if(1!==o.definitions.length)throw new Error("BabelPluginRelay: Expected exactly one definition per graphql tag.");var p=o.definitions[0];if("FragmentDefinition"!==p.kind&&"OperationDefinition"!==p.kind)throw new Error("BabelPluginRelay: Expected a fragment, mutation, query, or subscription, got `"+p.kind+"`.");var f=Boolean(t.opts&&t.opts.eagerESModules),c=Boolean(t.opts&&t.opts.haste),d=t.opts&&t.opts.isDevVariable;return function(e,r,t,o,p){var f=o.name&&o.name.value;if(!f)throw new Error("GraphQL operations and fragments must contain names");var c=f+".graphql",d=p.isHasteMode?c:p.artifactDirectory?function(e,r,t){if(null==e.file)throw new Error("Babel state is missing expected file name");var n=e.file.opts.filename,i=l(a(n),u(r));return(0!==i.length&&i.startsWith(".")?"":"./")+s(i,t)}(r,p.artifactDirectory,c):"./__generated__/"+c,g=n.createHash("md5").update(i(o),"utf8").digest("hex"),m=t.scope;for(;m.parent;)m=m.parent;var v=m.generateUidIdentifier(f),x=e.MemberExpression(v,e.Identifier("hash")),b=function(e,r,t){return e.callExpression(e.memberExpression(e.identifier("console"),e.identifier("error")),[e.stringLiteral("The definition of '".concat(r,"' appears to have changed. Run ")+"`"+t+"` to update the generated files to receive the expected data.")])}(e,f,p.buildCommand),h=e.LogicalExpression("&&",x,e.LogicalExpression("&&",e.BinaryExpression("!==",x,e.StringLiteral(g)),b));if(p.eagerESModules){var y=e.ImportDeclaration([e.ImportDefaultSpecifier(v)],e.StringLiteral(d));t.findParent((function(e){return e.isProgram()})).unshiftContainer("body",y);var E,q=e.SequenceExpression([h,v]);E=null!=p.isDevVariable?e.ConditionalExpression(e.Identifier(p.isDevVariable),q,v):p.isDevelopment?q:v,t.replaceWith(E)}else{m.push({id:v});var D,S=e.CallExpression(e.Identifier("require"),[e.StringLiteral(d)]),w=e.AssignmentExpression("=",v,S),j=e.SequenceExpression([w,h,v]);D=null!=p.isDevVariable?e.ConditionalExpression(e.Identifier(p.isDevVariable),j,w):p.isDevelopment?j:w;var P=e.UnaryExpression("void",e.NumericLiteral(0));t.replaceWith(e.ConditionalExpression(e.BinaryExpression("!==",v,P),v,D))}}(e,t,r,p,{artifactDirectory:t.opts&&t.opts.artifactDirectory,eagerESModules:f,buildCommand:t.opts&&t.opts.buildCommand||"relay-compiler",isDevelopment:"production"!==(process.env.BABEL_ENV||"development"),isHasteMode:c,isDevVariable:d})}},function(e,r){e.exports=require("crypto")},function(e,r){e.exports=require("path")},function(e,r,t){"use strict";var n=t(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 t=r[0].value.raw,i=n.parse(t);if(0===i.definitions.length)throw new Error("BabelPluginRelay: Unexpected empty graphql tag.");return i}},function(e,r){e.exports=require("cosmiconfig")}]);
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")}]);
@@ -1,9 +1,9 @@
1
1
  /**
2
- * Relay v13.0.0-rc.1
2
+ * Relay v13.0.2
3
3
  *
4
- * Copyright (c) Facebook, Inc. and its affiliates.
4
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
5
5
  *
6
6
  * This source code is licensed under the MIT license found in the
7
7
  * LICENSE file in the root directory of this source tree.
8
8
  */
9
- module.exports=function(e){var r={};function t(n){if(r[n])return r[n].exports;var i=r[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,t),i.l=!0,i.exports}return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:n})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,r){if(1&r&&(e=t(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var i in e)t.d(n,i,function(r){return e[r]}.bind(null,i));return n},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},t.p="",t(t.s=1)}([function(e,r){e.exports=require("graphql")},function(e,r,t){"use strict";var n,i=t(2)(t(3)),o=t(4),a=t(7),s=t(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&&(n=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 t={TaggedTemplateExpression:function(e,t){var n=a(e);n&&o(r,e,t,n)}};return{visitor:{Program:function(e,r){e.traverse(t,(0,i.default)((0,i.default)({},r),{},{opts:(0,i.default)((0,i.default)({},n),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,t){"use strict";var n=t(5),i=t(0).print,o=t(6),a=o.dirname,s=o.join,l=o.relative,u=o.resolve;e.exports=function(e,r,t,o){if(1!==o.definitions.length)throw new Error("BabelPluginRelay: Expected exactly one definition per graphql tag.");var p=o.definitions[0];if("FragmentDefinition"!==p.kind&&"OperationDefinition"!==p.kind)throw new Error("BabelPluginRelay: Expected a fragment, mutation, query, or subscription, got `"+p.kind+"`.");var f=Boolean(t.opts&&t.opts.eagerESModules),c=Boolean(t.opts&&t.opts.haste),d=t.opts&&t.opts.isDevVariable;return function(e,r,t,o,p){var f=o.name&&o.name.value;if(!f)throw new Error("GraphQL operations and fragments must contain names");var c=f+".graphql",d=p.isHasteMode?c:p.artifactDirectory?function(e,r,t){if(null==e.file)throw new Error("Babel state is missing expected file name");var n=e.file.opts.filename,i=l(a(n),u(r));return(0!==i.length&&i.startsWith(".")?"":"./")+s(i,t)}(r,p.artifactDirectory,c):"./__generated__/"+c,g=n.createHash("md5").update(i(o),"utf8").digest("hex"),m=t.scope;for(;m.parent;)m=m.parent;var v=m.generateUidIdentifier(f),x=e.MemberExpression(v,e.Identifier("hash")),b=function(e,r,t){return e.callExpression(e.memberExpression(e.identifier("console"),e.identifier("error")),[e.stringLiteral("The definition of '".concat(r,"' appears to have changed. Run ")+"`"+t+"` to update the generated files to receive the expected data.")])}(e,f,p.buildCommand),h=e.LogicalExpression("&&",x,e.LogicalExpression("&&",e.BinaryExpression("!==",x,e.StringLiteral(g)),b));if(p.eagerESModules){var y=e.ImportDeclaration([e.ImportDefaultSpecifier(v)],e.StringLiteral(d));t.findParent((function(e){return e.isProgram()})).unshiftContainer("body",y);var E,q=e.SequenceExpression([h,v]);E=null!=p.isDevVariable?e.ConditionalExpression(e.Identifier(p.isDevVariable),q,v):p.isDevelopment?q:v,t.replaceWith(E)}else{m.push({id:v});var D,S=e.CallExpression(e.Identifier("require"),[e.StringLiteral(d)]),w=e.AssignmentExpression("=",v,S),j=e.SequenceExpression([w,h,v]);D=null!=p.isDevVariable?e.ConditionalExpression(e.Identifier(p.isDevVariable),j,w):p.isDevelopment?j:w;var P=e.UnaryExpression("void",e.NumericLiteral(0));t.replaceWith(e.ConditionalExpression(e.BinaryExpression("!==",v,P),v,D))}}(e,t,r,p,{artifactDirectory:t.opts&&t.opts.artifactDirectory,eagerESModules:f,buildCommand:t.opts&&t.opts.buildCommand||"relay-compiler",isDevelopment:"production"!==(process.env.BABEL_ENV||"production"),isHasteMode:c,isDevVariable:d})}},function(e,r){e.exports=require("crypto")},function(e,r){e.exports=require("path")},function(e,r,t){"use strict";var n=t(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 t=r[0].value.raw,i=n.parse(t);if(0===i.definitions.length)throw new Error("BabelPluginRelay: Unexpected empty graphql tag.");return i}},function(e,r){e.exports=require("cosmiconfig")}]);
9
+ 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,c,f,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===(c=n.opts)||void 0===c?void 0:c.jsModuleFormat),y=null===(f=n.opts)||void 0===f?void 0:f.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 c=d+".graphql",f=p.isHasteMode?c: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,c):"./__generated__/"+c,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(f));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(f)]),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||"production"),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")}]);
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -56,19 +56,18 @@ function compileGraphQLTag(
56
56
  );
57
57
  }
58
58
 
59
- const eagerESModules = Boolean(state.opts && state.opts.eagerESModules);
60
- const isHasteMode = Boolean(state.opts && state.opts.haste);
61
- const isDevVariable = state.opts && state.opts.isDevVariable;
62
- const artifactDirectory = state.opts && state.opts.artifactDirectory;
63
- const buildCommand =
64
- (state.opts && state.opts.buildCommand) || 'relay-compiler';
59
+ const eagerEsModules = state.opts?.eagerEsModules ?? false;
60
+ const isHasteMode = state.opts?.jsModuleFormat === 'haste';
61
+ const isDevVariable = state.opts?.isDevVariableName;
62
+ const artifactDirectory = state.opts?.artifactDirectory;
63
+ const buildCommand = state.opts?.codegenCommand ?? 'relay-compiler';
65
64
  // Fallback is 'true'
66
65
  const isDevelopment =
67
66
  (process.env.BABEL_ENV || process.env.NODE_ENV) !== 'production';
68
67
 
69
68
  return createNode(t, state, path, definition, {
70
69
  artifactDirectory,
71
- eagerESModules,
70
+ eagerEsModules,
72
71
  buildCommand,
73
72
  isDevelopment,
74
73
  isHasteMode,
@@ -91,7 +90,7 @@ function createNode(
91
90
  // If an output directory is specified when running relay-compiler this should point to that directory
92
91
  artifactDirectory: ?string,
93
92
  // Generate eager es modules instead of lazy require
94
- eagerESModules: boolean,
93
+ eagerEsModules: boolean,
95
94
  // The command to run to compile Relay files, used for error messages.
96
95
  buildCommand: string,
97
96
  // Generate extra validation, defaults to true.
@@ -137,7 +136,7 @@ function createNode(
137
136
  ),
138
137
  );
139
138
 
140
- if (options.eagerESModules) {
139
+ if (options.eagerEsModules) {
141
140
  const importDeclaration = t.ImportDeclaration(
142
141
  [t.ImportDefaultSpecifier(id)],
143
142
  t.StringLiteral(requiredPath),
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
package/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
- * Relay v13.0.0-rc.1
2
+ * Relay v13.0.2
3
3
  *
4
- * Copyright (c) Facebook, Inc. and its affiliates.
4
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
5
5
  *
6
6
  * This source code is licensed under the MIT license found in the
7
7
  * LICENSE file in the root directory of this source tree.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -27,6 +27,8 @@ var GENERATED = './__generated__/';
27
27
  */
28
28
 
29
29
  function compileGraphQLTag(t, path, state, ast) {
30
+ var _state$opts$eagerEsMo, _state$opts, _state$opts2, _state$opts3, _state$opts4, _state$opts$codegenCo, _state$opts5;
31
+
30
32
  if (ast.definitions.length !== 1) {
31
33
  throw new Error('BabelPluginRelay: Expected exactly one definition per graphql tag.');
32
34
  }
@@ -37,16 +39,16 @@ function compileGraphQLTag(t, path, state, ast) {
37
39
  throw new Error('BabelPluginRelay: Expected a fragment, mutation, query, or ' + 'subscription, got `' + definition.kind + '`.');
38
40
  }
39
41
 
40
- var eagerESModules = Boolean(state.opts && state.opts.eagerESModules);
41
- var isHasteMode = Boolean(state.opts && state.opts.haste);
42
- var isDevVariable = state.opts && state.opts.isDevVariable;
43
- var artifactDirectory = state.opts && state.opts.artifactDirectory;
44
- var buildCommand = state.opts && state.opts.buildCommand || 'relay-compiler'; // Fallback is 'true'
42
+ var eagerEsModules = (_state$opts$eagerEsMo = (_state$opts = state.opts) === null || _state$opts === void 0 ? void 0 : _state$opts.eagerEsModules) !== null && _state$opts$eagerEsMo !== void 0 ? _state$opts$eagerEsMo : false;
43
+ var isHasteMode = ((_state$opts2 = state.opts) === null || _state$opts2 === void 0 ? void 0 : _state$opts2.jsModuleFormat) === 'haste';
44
+ var isDevVariable = (_state$opts3 = state.opts) === null || _state$opts3 === void 0 ? void 0 : _state$opts3.isDevVariableName;
45
+ var artifactDirectory = (_state$opts4 = state.opts) === null || _state$opts4 === void 0 ? void 0 : _state$opts4.artifactDirectory;
46
+ var buildCommand = (_state$opts$codegenCo = (_state$opts5 = state.opts) === null || _state$opts5 === void 0 ? void 0 : _state$opts5.codegenCommand) !== null && _state$opts$codegenCo !== void 0 ? _state$opts$codegenCo : 'relay-compiler'; // Fallback is 'true'
45
47
 
46
48
  var isDevelopment = (process.env.BABEL_ENV || process.env.NODE_ENV) !== 'production';
47
49
  return createNode(t, state, path, definition, {
48
50
  artifactDirectory: artifactDirectory,
49
- eagerESModules: eagerESModules,
51
+ eagerEsModules: eagerEsModules,
50
52
  buildCommand: buildCommand,
51
53
  isDevelopment: isDevelopment,
52
54
  isHasteMode: isHasteMode,
@@ -82,7 +84,7 @@ function createNode(t, state, path, graphqlDefinition, options) {
82
84
  var expWarn = warnNeedsRebuild(t, definitionName, options.buildCommand);
83
85
  var expWarnIfOutdated = t.LogicalExpression('&&', expHash, t.LogicalExpression('&&', t.BinaryExpression('!==', expHash, t.StringLiteral(hash)), expWarn));
84
86
 
85
- if (options.eagerESModules) {
87
+ if (options.eagerEsModules) {
86
88
  var importDeclaration = t.ImportDeclaration([t.ImportDefaultSpecifier(id)], t.StringLiteral(requiredPath));
87
89
  var program = path.findParent(function (parent) {
88
90
  return parent.isProgram();
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
package/macro.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
- * Relay v13.0.0-rc.1
2
+ * Relay v13.0.2
3
3
  *
4
- * Copyright (c) Facebook, Inc. and its affiliates.
4
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
5
5
  *
6
6
  * This source code is licensed under the MIT license found in the
7
7
  * LICENSE file in the root directory of this source tree.
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.0.0-rc.1",
4
+ "version": "13.0.2",
5
5
  "keywords": [
6
6
  "graphql",
7
7
  "relay",