babel-plugin-relay 15.0.0 → 16.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,4 @@
1
1
  /**
2
- * Relay v15.0.0
2
+ * Relay v16.1.0
3
3
  */
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=(0,n(2).default)(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")}]);
4
+ (()=>{"use strict";var e={364:(e,r,i)=>{var n,o=(0,i(193).default)(i(56)),t=i(76),a=i(743),l=i(399),s=l("relay",{searchPlaces:["relay.config.js","relay.config.json","package.json"],loaders:{".json":l.loadJson,".js":l.loadJs,noExt:l.loadYaml}}).searchSync();s&&(n=s.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 i={TaggedTemplateExpression:function(e,i){var n=a(e);n&&t(r,e,i,n)}};return{visitor:{Program:function(e,r){e.traverse(i,(0,o.default)((0,o.default)({},r),{},{opts:(0,o.default)((0,o.default)({},n),r.opts)}))}}}}},76:(e,r,i)=>{var n=i(770),o=i(174).print,t=i(315),a=t.dirname,l=t.join,s=t.relative,d=t.resolve;e.exports=function(e,r,i,t){var p,u,c,f,g,v,m;if(1!==t.definitions.length)throw new Error("BabelPluginRelay: Expected exactly one definition per graphql tag.");var x=t.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===(u=i.opts)||void 0===u?void 0:u.eagerEsModules)&&void 0!==p&&p,E="haste"===(null===(c=i.opts)||void 0===c?void 0:c.jsModuleFormat),b=null===(f=i.opts)||void 0===f?void 0:f.isDevVariableName;return function(e,r,i,t,p){var u=t.name&&t.name.value;if(!u)throw new Error("GraphQL operations and fragments must contain names");for(var c=u+".graphql",f=p.isHasteMode?c:p.artifactDirectory?function(e,r,i){if(null==e.file)throw new Error("Babel state is missing expected file name");var n=e.file.opts.filename,o=s(a(n),d(r));return(0!==o.length&&o.startsWith(".")?"":"./")+l(o,i)}(r,p.artifactDirectory,c):"./__generated__/"+c,g=n.createHash("md5").update(o(t),"utf8").digest("hex"),v=i.scope;v.parent;)v=v.parent;var m=v.generateUidIdentifier(u),x=e.MemberExpression(e.cloneNode(m),e.Identifier("hash")),h=function(e,r,i){return e.callExpression(e.memberExpression(e.identifier("console"),e.identifier("error")),[e.stringLiteral("The definition of '".concat(r,"' appears to have changed. Run ")+"`"+i+"` to update the generated files to receive the expected data.")])}(e,u,p.buildCommand),E=e.LogicalExpression("&&",e.cloneNode(x),e.LogicalExpression("&&",e.BinaryExpression("!==",x,e.StringLiteral(g)),h));if(p.eagerEsModules){var b=e.ImportDeclaration([e.ImportDefaultSpecifier(m)],e.StringLiteral(f));i.findParent((function(e){return e.isProgram()})).unshiftContainer("body",b);var y,q=e.SequenceExpression([E,e.cloneNode(m)]);y=null!=p.isDevVariable?e.ConditionalExpression(e.Identifier(p.isDevVariable),q,e.cloneNode(m)):p.isDevelopment?q:e.cloneNode(m),i.replaceWith(y)}else{v.push({id:e.cloneNode(m)});var D,w=e.CallExpression(e.Identifier("require"),[e.StringLiteral(f)]),N=e.AssignmentExpression("=",e.cloneNode(m),w),B=e.SequenceExpression([N,E,e.cloneNode(m)]);D=null!=p.isDevVariable?e.ConditionalExpression(e.Identifier(p.isDevVariable),B,N):p.isDevelopment?B:N;var P=e.UnaryExpression("void",e.NumericLiteral(0));i.replaceWith(e.ConditionalExpression(e.BinaryExpression("!==",e.cloneNode(m),P),e.cloneNode(m),e.cloneNode(D)))}}(e,i,r,x,{artifactDirectory:null===(g=i.opts)||void 0===g?void 0:g.artifactDirectory,eagerEsModules:h,buildCommand:null!==(v=null===(m=i.opts)||void 0===m?void 0:m.codegenCommand)&&void 0!==v?v:"relay-compiler",isDevelopment:"production"!==(process.env.BABEL_ENV||"development"),isHasteMode:E,isDevVariable:b})}},743:(e,r,i)=>{var n=i(174);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 i=r[0].value.raw,o=n.parse(i);if(0===o.definitions.length)throw new Error("BabelPluginRelay: Unexpected empty graphql tag.");return o}},193:e=>{e.exports=require("@babel/runtime/helpers/interopRequireDefault")},56:e=>{e.exports=require("@babel/runtime/helpers/objectSpread2")},399:e=>{e.exports=require("cosmiconfig")},770:e=>{e.exports=require("crypto")},174:e=>{e.exports=require("graphql")},315:e=>{e.exports=require("path")}},r={},i=function i(n){var o=r[n];if(void 0!==o)return o.exports;var t=r[n]={exports:{}};return e[n](t,t.exports,i),t.exports}(364);module.exports.BabelPluginRelay=i})();
@@ -1,9 +1,9 @@
1
1
  /**
2
- * Relay v15.0.0
2
+ * Relay v16.1.0
3
3
  *
4
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 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=(0,n(2).default)(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||"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")}]);
9
+ (()=>{"use strict";var e={364:(e,r,i)=>{var n,o=(0,i(193).default)(i(56)),t=i(76),a=i(743),s=i(399),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 i={TaggedTemplateExpression:function(e,i){var n=a(e);n&&t(r,e,i,n)}};return{visitor:{Program:function(e,r){e.traverse(i,(0,o.default)((0,o.default)({},r),{},{opts:(0,o.default)((0,o.default)({},n),r.opts)}))}}}}},76:(e,r,i)=>{var n=i(770),o=i(174).print,t=i(315),a=t.dirname,s=t.join,l=t.relative,d=t.resolve;e.exports=function(e,r,i,t){var p,u,c,f,g,v,m;if(1!==t.definitions.length)throw new Error("BabelPluginRelay: Expected exactly one definition per graphql tag.");var x=t.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===(u=i.opts)||void 0===u?void 0:u.eagerEsModules)&&void 0!==p&&p,E="haste"===(null===(c=i.opts)||void 0===c?void 0:c.jsModuleFormat),b=null===(f=i.opts)||void 0===f?void 0:f.isDevVariableName;return function(e,r,i,t,p){var u=t.name&&t.name.value;if(!u)throw new Error("GraphQL operations and fragments must contain names");for(var c=u+".graphql",f=p.isHasteMode?c:p.artifactDirectory?function(e,r,i){if(null==e.file)throw new Error("Babel state is missing expected file name");var n=e.file.opts.filename,o=l(a(n),d(r));return(0!==o.length&&o.startsWith(".")?"":"./")+s(o,i)}(r,p.artifactDirectory,c):"./__generated__/"+c,g=n.createHash("md5").update(o(t),"utf8").digest("hex"),v=i.scope;v.parent;)v=v.parent;var m=v.generateUidIdentifier(u),x=e.MemberExpression(e.cloneNode(m),e.Identifier("hash")),h=function(e,r,i){return e.callExpression(e.memberExpression(e.identifier("console"),e.identifier("error")),[e.stringLiteral("The definition of '".concat(r,"' appears to have changed. Run ")+"`"+i+"` to update the generated files to receive the expected data.")])}(e,u,p.buildCommand),E=e.LogicalExpression("&&",e.cloneNode(x),e.LogicalExpression("&&",e.BinaryExpression("!==",x,e.StringLiteral(g)),h));if(p.eagerEsModules){var b=e.ImportDeclaration([e.ImportDefaultSpecifier(m)],e.StringLiteral(f));i.findParent((function(e){return e.isProgram()})).unshiftContainer("body",b);var y,q=e.SequenceExpression([E,e.cloneNode(m)]);y=null!=p.isDevVariable?e.ConditionalExpression(e.Identifier(p.isDevVariable),q,e.cloneNode(m)):p.isDevelopment?q:e.cloneNode(m),i.replaceWith(y)}else{v.push({id:e.cloneNode(m)});var D,w=e.CallExpression(e.Identifier("require"),[e.StringLiteral(f)]),N=e.AssignmentExpression("=",e.cloneNode(m),w),B=e.SequenceExpression([N,E,e.cloneNode(m)]);D=null!=p.isDevVariable?e.ConditionalExpression(e.Identifier(p.isDevVariable),B,N):p.isDevelopment?B:N;var P=e.UnaryExpression("void",e.NumericLiteral(0));i.replaceWith(e.ConditionalExpression(e.BinaryExpression("!==",e.cloneNode(m),P),e.cloneNode(m),e.cloneNode(D)))}}(e,i,r,x,{artifactDirectory:null===(g=i.opts)||void 0===g?void 0:g.artifactDirectory,eagerEsModules:h,buildCommand:null!==(v=null===(m=i.opts)||void 0===m?void 0:m.codegenCommand)&&void 0!==v?v:"relay-compiler",isDevelopment:"production"!==(process.env.BABEL_ENV||"production"),isHasteMode:E,isDevVariable:b})}},743:(e,r,i)=>{var n=i(174);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 i=r[0].value.raw,o=n.parse(i);if(0===o.definitions.length)throw new Error("BabelPluginRelay: Unexpected empty graphql tag.");return o}},193:e=>{e.exports=require("@babel/runtime/helpers/interopRequireDefault")},56:e=>{e.exports=require("@babel/runtime/helpers/objectSpread2")},399:e=>{e.exports=require("cosmiconfig")},770:e=>{e.exports=require("crypto")},174:e=>{e.exports=require("graphql")},315:e=>{e.exports=require("path")}},r={},i=function i(n){var o=r[n];if(void 0!==o)return o.exports;var t=r[n]={exports:{}};return e[n](t,t.exports,i),t.exports}(364);module.exports.BabelPluginRelay=i})();
@@ -125,11 +125,11 @@ function createNode(
125
125
 
126
126
  const id = topScope.generateUidIdentifier(definitionName);
127
127
 
128
- const expHash = t.MemberExpression(id, t.Identifier('hash'));
128
+ const expHash = t.MemberExpression(t.cloneNode(id), t.Identifier('hash'));
129
129
  const expWarn = warnNeedsRebuild(t, definitionName, options.buildCommand);
130
130
  const expWarnIfOutdated = t.LogicalExpression(
131
131
  '&&',
132
- expHash,
132
+ t.cloneNode(expHash),
133
133
  t.LogicalExpression(
134
134
  '&&',
135
135
  t.BinaryExpression('!==', expHash, t.StringLiteral(hash)),
@@ -145,34 +145,41 @@ function createNode(
145
145
  const program = path.findParent(parent => parent.isProgram());
146
146
  program.unshiftContainer('body', importDeclaration);
147
147
 
148
- const expAssignAndCheck = t.SequenceExpression([expWarnIfOutdated, id]);
148
+ const expAssignAndCheck = t.SequenceExpression([
149
+ expWarnIfOutdated,
150
+ t.cloneNode(id),
151
+ ]);
149
152
 
150
153
  let expAssign;
151
154
  if (options.isDevVariable != null) {
152
155
  expAssign = t.ConditionalExpression(
153
156
  t.Identifier(options.isDevVariable),
154
157
  expAssignAndCheck,
155
- id,
158
+ t.cloneNode(id),
156
159
  );
157
160
  } else if (options.isDevelopment) {
158
161
  expAssign = expAssignAndCheck;
159
162
  } else {
160
- expAssign = id;
163
+ expAssign = t.cloneNode(id);
161
164
  }
162
165
 
163
166
  path.replaceWith(expAssign);
164
167
  } else {
165
- topScope.push({id});
168
+ topScope.push({id: t.cloneNode(id)});
166
169
 
167
170
  const requireGraphQLModule = t.CallExpression(t.Identifier('require'), [
168
171
  t.StringLiteral(requiredPath),
169
172
  ]);
170
173
 
171
- const expAssignProd = t.AssignmentExpression('=', id, requireGraphQLModule);
174
+ const expAssignProd = t.AssignmentExpression(
175
+ '=',
176
+ t.cloneNode(id),
177
+ requireGraphQLModule,
178
+ );
172
179
  const expAssignAndCheck = t.SequenceExpression([
173
180
  expAssignProd,
174
181
  expWarnIfOutdated,
175
- id,
182
+ t.cloneNode(id),
176
183
  ]);
177
184
 
178
185
  let expAssign;
@@ -191,9 +198,9 @@ function createNode(
191
198
  const expVoid0 = t.UnaryExpression('void', t.NumericLiteral(0));
192
199
  path.replaceWith(
193
200
  t.ConditionalExpression(
194
- t.BinaryExpression('!==', id, expVoid0),
195
- id,
196
- expAssign,
201
+ t.BinaryExpression('!==', t.cloneNode(id), expVoid0),
202
+ t.cloneNode(id),
203
+ t.cloneNode(expAssign),
197
204
  ),
198
205
  );
199
206
  }
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Relay v15.0.0
2
+ * Relay v16.1.0
3
3
  *
4
4
  * Copyright (c) Meta Platforms, Inc. and affiliates.
5
5
  *
@@ -1,14 +1,3 @@
1
- /**
2
- * Copyright (c) Meta Platforms, Inc. and affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- *
8
- * @format
9
- * @oncall relay
10
- */
11
-
12
1
  'use strict';
13
2
 
14
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
@@ -29,15 +18,6 @@ var result = configExplorer.searchSync();
29
18
  if (result) {
30
19
  RelayConfig = result.config;
31
20
  }
32
- /**
33
- * Using babel-plugin-relay with only the modern runtime?
34
- *
35
- * {
36
- * plugins: [
37
- * "relay"
38
- * ]
39
- * }
40
- */
41
21
  module.exports = function BabelPluginRelay(context) {
42
22
  var t = context.types;
43
23
  if (!t) {
@@ -45,7 +25,6 @@ module.exports = function BabelPluginRelay(context) {
45
25
  }
46
26
  var visitor = {
47
27
  TaggedTemplateExpression: function TaggedTemplateExpression(path, state) {
48
- // Convert graphql`` literals
49
28
  var ast = getValidGraphQLTag(path);
50
29
  if (ast) {
51
30
  compileGraphQLTag(t, path, state, ast);
@@ -1,14 +1,3 @@
1
- /**
2
- * Copyright (c) Meta Platforms, Inc. and affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- *
8
- * @format
9
- * @oncall relay
10
- */
11
-
12
1
  'use strict';
13
2
 
14
3
  var compileGraphQLTag = require('./compileGraphQLTag');
@@ -1,14 +1,3 @@
1
- /**
2
- * Copyright (c) Meta Platforms, Inc. and affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- *
8
- * @format
9
- * @oncall relay
10
- */
11
-
12
1
  'use strict';
13
2
 
14
3
  var crypto = require('crypto');
@@ -20,11 +9,6 @@ var _require2 = require('path'),
20
9
  relativePath = _require2.relative,
21
10
  resolvePath = _require2.resolve;
22
11
  var GENERATED = './__generated__/';
23
-
24
- /**
25
- * Given a graphql`` tagged template literal, replace it with the appropriate
26
- * runtime artifact.
27
- */
28
12
  function compileGraphQLTag(t, path, state, ast) {
29
13
  var _state$opts$eagerEsMo, _state$opts, _state$opts2, _state$opts3, _state$opts4, _state$opts$codegenCo, _state$opts5;
30
14
  if (ast.definitions.length !== 1) {
@@ -39,7 +23,6 @@ function compileGraphQLTag(t, path, state, ast) {
39
23
  var isDevVariable = (_state$opts3 = state.opts) === null || _state$opts3 === void 0 ? void 0 : _state$opts3.isDevVariableName;
40
24
  var artifactDirectory = (_state$opts4 = state.opts) === null || _state$opts4 === void 0 ? void 0 : _state$opts4.artifactDirectory;
41
25
  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';
42
- // Fallback is 'true'
43
26
  var isDevelopment = (process.env.BABEL_ENV || process.env.NODE_ENV) !== 'production';
44
27
  return createNode(t, state, path, definition, {
45
28
  artifactDirectory: artifactDirectory,
@@ -50,13 +33,6 @@ function compileGraphQLTag(t, path, state, ast) {
50
33
  isDevVariable: isDevVariable
51
34
  });
52
35
  }
53
-
54
- /**
55
- * The Relay compiler generates separate modules that contain the compiled code.
56
- * Here we generate:
57
- * - a memoized `require` call for that generated code
58
- * - for development mode, runtime validation that the artifacts are up to date
59
- */
60
36
  function createNode(t, state, path, graphqlDefinition, options) {
61
37
  var definitionName = graphqlDefinition.name && graphqlDefinition.name.value;
62
38
  if (!definitionName) {
@@ -70,32 +46,32 @@ function createNode(t, state, path, graphqlDefinition, options) {
70
46
  topScope = topScope.parent;
71
47
  }
72
48
  var id = topScope.generateUidIdentifier(definitionName);
73
- var expHash = t.MemberExpression(id, t.Identifier('hash'));
49
+ var expHash = t.MemberExpression(t.cloneNode(id), t.Identifier('hash'));
74
50
  var expWarn = warnNeedsRebuild(t, definitionName, options.buildCommand);
75
- var expWarnIfOutdated = t.LogicalExpression('&&', expHash, t.LogicalExpression('&&', t.BinaryExpression('!==', expHash, t.StringLiteral(hash)), expWarn));
51
+ var expWarnIfOutdated = t.LogicalExpression('&&', t.cloneNode(expHash), t.LogicalExpression('&&', t.BinaryExpression('!==', expHash, t.StringLiteral(hash)), expWarn));
76
52
  if (options.eagerEsModules) {
77
53
  var importDeclaration = t.ImportDeclaration([t.ImportDefaultSpecifier(id)], t.StringLiteral(requiredPath));
78
54
  var program = path.findParent(function (parent) {
79
55
  return parent.isProgram();
80
56
  });
81
57
  program.unshiftContainer('body', importDeclaration);
82
- var expAssignAndCheck = t.SequenceExpression([expWarnIfOutdated, id]);
58
+ var expAssignAndCheck = t.SequenceExpression([expWarnIfOutdated, t.cloneNode(id)]);
83
59
  var expAssign;
84
60
  if (options.isDevVariable != null) {
85
- expAssign = t.ConditionalExpression(t.Identifier(options.isDevVariable), expAssignAndCheck, id);
61
+ expAssign = t.ConditionalExpression(t.Identifier(options.isDevVariable), expAssignAndCheck, t.cloneNode(id));
86
62
  } else if (options.isDevelopment) {
87
63
  expAssign = expAssignAndCheck;
88
64
  } else {
89
- expAssign = id;
65
+ expAssign = t.cloneNode(id);
90
66
  }
91
67
  path.replaceWith(expAssign);
92
68
  } else {
93
69
  topScope.push({
94
- id: id
70
+ id: t.cloneNode(id)
95
71
  });
96
72
  var requireGraphQLModule = t.CallExpression(t.Identifier('require'), [t.StringLiteral(requiredPath)]);
97
- var expAssignProd = t.AssignmentExpression('=', id, requireGraphQLModule);
98
- var _expAssignAndCheck = t.SequenceExpression([expAssignProd, expWarnIfOutdated, id]);
73
+ var expAssignProd = t.AssignmentExpression('=', t.cloneNode(id), requireGraphQLModule);
74
+ var _expAssignAndCheck = t.SequenceExpression([expAssignProd, expWarnIfOutdated, t.cloneNode(id)]);
99
75
  var _expAssign;
100
76
  if (options.isDevVariable != null) {
101
77
  _expAssign = t.ConditionalExpression(t.Identifier(options.isDevVariable), _expAssignAndCheck, expAssignProd);
@@ -105,7 +81,7 @@ function createNode(t, state, path, graphqlDefinition, options) {
105
81
  _expAssign = expAssignProd;
106
82
  }
107
83
  var expVoid0 = t.UnaryExpression('void', t.NumericLiteral(0));
108
- path.replaceWith(t.ConditionalExpression(t.BinaryExpression('!==', id, expVoid0), id, _expAssign));
84
+ path.replaceWith(t.ConditionalExpression(t.BinaryExpression('!==', t.cloneNode(id), expVoid0), t.cloneNode(id), t.cloneNode(_expAssign)));
109
85
  }
110
86
  }
111
87
  function warnNeedsRebuild(t, definitionName, buildCommand) {
@@ -1,23 +1,6 @@
1
- /**
2
- * Copyright (c) Meta Platforms, Inc. and affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- *
8
- * @format
9
- * @oncall relay
10
- */
11
-
12
1
  'use strict';
13
2
 
14
3
  var GraphQL = require('graphql');
15
-
16
- /**
17
- * Given a babel AST path to a tagged template literal, return an AST if it is
18
- * a graphql literal being used in a valid way.
19
- * If it is some other type of template literal then return nothing.
20
- */
21
4
  function getValidGraphQLTag(path) {
22
5
  var tag = path.get('tag');
23
6
  if (!tag.isIdentifier({
package/macro.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Relay v15.0.0
2
+ * Relay v16.1.0
3
3
  *
4
4
  * Copyright (c) Meta Platforms, Inc. and affiliates.
5
5
  *
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": "15.0.0",
4
+ "version": "16.1.0",
5
5
  "keywords": [
6
6
  "graphql",
7
7
  "relay",
@@ -23,6 +23,7 @@
23
23
  },
24
24
  "devDependencies": {
25
25
  "@babel/core": "^7.20.0",
26
- "prettier": "2.7.1"
26
+ "prettier": "2.8.8",
27
+ "prettier-plugin-hermes-parser": "0.18.0"
27
28
  }
28
29
  }