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.
- package/babel-plugin-relay.js +2 -2
- package/babel-plugin-relay.min.js +2 -2
- package/compileGraphQLTag.js.flow +18 -11
- package/index.js +1 -1
- package/lib/BabelPluginRelay.js +0 -21
- package/lib/BabelPluginRelay.macro.js +0 -11
- package/lib/compileGraphQLTag.js +9 -33
- package/lib/getValidGraphQLTag.js +0 -17
- package/macro.js +1 -1
- package/package.json +3 -2
package/babel-plugin-relay.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
1
|
/**
|
2
|
-
* Relay
|
2
|
+
* Relay v16.1.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=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
|
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
|
-
|
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([
|
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(
|
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
package/lib/BabelPluginRelay.js
CHANGED
@@ -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');
|
package/lib/compileGraphQLTag.js
CHANGED
@@ -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
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": "
|
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.
|
26
|
+
"prettier": "2.8.8",
|
27
|
+
"prettier-plugin-hermes-parser": "0.18.0"
|
27
28
|
}
|
28
29
|
}
|