babel-plugin-relay 16.0.0 → 16.2.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.
- package/babel-plugin-relay.js +2 -2
- package/babel-plugin-relay.min.js +2 -2
- package/compileGraphQLTag.js.flow +15 -5
- package/index.js +1 -1
- package/lib/compileGraphQLTag.js +4 -1
- package/macro.js +1 -1
- package/package.json +2 -2
package/babel-plugin-relay.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Relay v16.
|
|
2
|
+
* Relay v16.2.0
|
|
3
3
|
*/
|
|
4
|
-
|
|
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 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Relay v16.
|
|
2
|
+
* Relay v16.2.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
|
-
|
|
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})();
|
|
@@ -29,6 +29,14 @@ const {
|
|
|
29
29
|
|
|
30
30
|
const GENERATED = './__generated__/';
|
|
31
31
|
|
|
32
|
+
/**
|
|
33
|
+
* Converts backslashes in a path to forward slashes (POSIX style) for
|
|
34
|
+
* cross-platform compatibility.
|
|
35
|
+
*/
|
|
36
|
+
function posixifyPath(path: string): string {
|
|
37
|
+
return process.platform === 'win32' ? path.replace(/\\/g, '/') : path;
|
|
38
|
+
}
|
|
39
|
+
|
|
32
40
|
/**
|
|
33
41
|
* Given a graphql`` tagged template literal, replace it with the appropriate
|
|
34
42
|
* runtime artifact.
|
|
@@ -107,11 +115,13 @@ function createNode(
|
|
|
107
115
|
throw new Error('GraphQL operations and fragments must contain names');
|
|
108
116
|
}
|
|
109
117
|
const requiredFile = definitionName + '.graphql';
|
|
110
|
-
const requiredPath =
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
118
|
+
const requiredPath = posixifyPath(
|
|
119
|
+
options.isHasteMode
|
|
120
|
+
? requiredFile
|
|
121
|
+
: options.artifactDirectory
|
|
122
|
+
? getRelativeImportPath(state, options.artifactDirectory, requiredFile)
|
|
123
|
+
: GENERATED + requiredFile,
|
|
124
|
+
);
|
|
115
125
|
|
|
116
126
|
const hash = crypto
|
|
117
127
|
.createHash('md5')
|
package/index.js
CHANGED
package/lib/compileGraphQLTag.js
CHANGED
|
@@ -9,6 +9,9 @@ var _require2 = require('path'),
|
|
|
9
9
|
relativePath = _require2.relative,
|
|
10
10
|
resolvePath = _require2.resolve;
|
|
11
11
|
var GENERATED = './__generated__/';
|
|
12
|
+
function posixifyPath(path) {
|
|
13
|
+
return process.platform === 'win32' ? path.replace(/\\/g, '/') : path;
|
|
14
|
+
}
|
|
12
15
|
function compileGraphQLTag(t, path, state, ast) {
|
|
13
16
|
var _state$opts$eagerEsMo, _state$opts, _state$opts2, _state$opts3, _state$opts4, _state$opts$codegenCo, _state$opts5;
|
|
14
17
|
if (ast.definitions.length !== 1) {
|
|
@@ -39,7 +42,7 @@ function createNode(t, state, path, graphqlDefinition, options) {
|
|
|
39
42
|
throw new Error('GraphQL operations and fragments must contain names');
|
|
40
43
|
}
|
|
41
44
|
var requiredFile = definitionName + '.graphql';
|
|
42
|
-
var requiredPath = options.isHasteMode ? requiredFile : options.artifactDirectory ? getRelativeImportPath(state, options.artifactDirectory, requiredFile) : GENERATED + requiredFile;
|
|
45
|
+
var requiredPath = posixifyPath(options.isHasteMode ? requiredFile : options.artifactDirectory ? getRelativeImportPath(state, options.artifactDirectory, requiredFile) : GENERATED + requiredFile);
|
|
43
46
|
var hash = crypto.createHash('md5').update(print(graphqlDefinition), 'utf8').digest('hex');
|
|
44
47
|
var topScope = path.scope;
|
|
45
48
|
while (topScope.parent) {
|
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": "16.
|
|
4
|
+
"version": "16.2.0",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"graphql",
|
|
7
7
|
"relay",
|
|
@@ -24,6 +24,6 @@
|
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@babel/core": "^7.20.0",
|
|
26
26
|
"prettier": "2.8.8",
|
|
27
|
-
"prettier-plugin-hermes-parser": "0.
|
|
27
|
+
"prettier-plugin-hermes-parser": "0.18.2"
|
|
28
28
|
}
|
|
29
29
|
}
|