babel-plugin-relay 18.1.0 → 19.0.0

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.
@@ -27,6 +27,7 @@ function BabelPluginRelayMacro({references, state, babel, config}: any) {
27
27
  compileGraphQLTag(
28
28
  t,
29
29
  path,
30
+ // $FlowFixMe[unsafe-object-assign]
30
31
  Object.assign(state, config ? {opts: config} : {}),
31
32
  ast,
32
33
  );
@@ -18,6 +18,7 @@ import type {
18
18
  OperationDefinitionNode,
19
19
  } from 'graphql';
20
20
 
21
+ // $FlowFixMe[cannot-resolve-module]
21
22
  const crypto = require('crypto');
22
23
  const {print} = require('graphql');
23
24
  const {
@@ -25,6 +26,7 @@ const {
25
26
  join: joinPath,
26
27
  relative: relativePath,
27
28
  resolve: resolvePath,
29
+ // $FlowFixMe[cannot-resolve-module]
28
30
  } = require('path');
29
31
 
30
32
  const GENERATED = './__generated__/';
@@ -34,6 +36,7 @@ const GENERATED = './__generated__/';
34
36
  * cross-platform compatibility.
35
37
  */
36
38
  function posixifyPath(path: string): string {
39
+ // $FlowFixMe[cannot-resolve-name]
37
40
  return process.platform === 'win32' ? path.replace(/\\/g, '/') : path;
38
41
  }
39
42
 
@@ -72,6 +75,7 @@ function compileGraphQLTag(
72
75
  const buildCommand = state.opts?.codegenCommand ?? 'relay-compiler';
73
76
  // Fallback is 'true'
74
77
  const isDevelopment =
78
+ // $FlowFixMe[cannot-resolve-name]
75
79
  (process.env.BABEL_ENV || process.env.NODE_ENV) !== 'production';
76
80
 
77
81
  return createNode(t, state, path, definition, {
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Relay v18.1.0
2
+ * Relay v19.0.0
3
3
  *
4
4
  * Copyright (c) Meta Platforms, Inc. and affiliates.
5
5
  *
package/macro.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Relay v18.1.0
2
+ * Relay v19.0.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": "18.1.0",
4
+ "version": "19.0.0",
5
5
  "keywords": [
6
6
  "graphql",
7
7
  "relay",
@@ -24,6 +24,6 @@
24
24
  "devDependencies": {
25
25
  "@babel/core": "^7.25.2",
26
26
  "prettier": "2.8.8",
27
- "prettier-plugin-hermes-parser": "0.24.0"
27
+ "prettier-plugin-hermes-parser": "0.28.1"
28
28
  }
29
29
  }
@@ -1,4 +0,0 @@
1
- /**
2
- * Relay v18.1.0
3
- */
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=function(e){return"win32"===process.platform?e.replace(/\\/g,"/"):e}(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 +0,0 @@
1
- /**
2
- * Relay v18.1.0
3
- *
4
- * Copyright (c) Meta Platforms, Inc. and affiliates.
5
- *
6
- * This source code is licensed under the MIT license found in the
7
- * LICENSE file in the root directory of this source tree.
8
- */
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=function(e){return"win32"===process.platform?e.replace(/\\/g,"/"):e}(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})();