@mo36924/babel-plugin-graphql-tagged-template 5.0.56 → 5.1.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.cjs +15 -13
- package/dist/index.js +15 -13
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
@@ -22,19 +22,19 @@ var index = helperPluginUtils.declare((_, { schema, development, queries = queri
|
|
22
22
|
return {
|
23
23
|
name: "babel-plugin-graphql-tagged-template",
|
24
24
|
visitor: {
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
25
|
+
...development ? {} : {
|
26
|
+
VariableDeclarator (path, { filename = "" }) {
|
27
|
+
if (!(queriesPaths.includes(filename) && path.get("id").isIdentifier({
|
28
|
+
name: "queries"
|
29
|
+
}) && path.get("init").isObjectExpression())) {
|
30
|
+
return;
|
31
|
+
}
|
32
|
+
path.get("init").replaceWith(core.types.objectExpression(queries.sort().map((query)=>core.types.objectProperty(core.types.identifier(hash(query)), core.types.callExpression(core.types.memberExpression(core.types.identifier("JSON"), core.types.identifier("parse")), [
|
33
|
+
core.types.stringLiteral(JSON.stringify(graphql.parse(query, {
|
34
|
+
noLocation: true
|
35
|
+
})))
|
36
|
+
])))));
|
30
37
|
}
|
31
|
-
path.get("init").replaceWith(core.types.objectExpression([
|
32
|
-
...new Set(queries)
|
33
|
-
].sort().map((query)=>core.types.objectProperty(core.types.identifier(hash(query)), core.types.callExpression(core.types.memberExpression(core.types.identifier("JSON"), core.types.identifier("parse")), [
|
34
|
-
core.types.stringLiteral(JSON.stringify(graphql.parse(query, {
|
35
|
-
noLocation: true
|
36
|
-
})))
|
37
|
-
])))));
|
38
38
|
},
|
39
39
|
TaggedTemplateExpression (path) {
|
40
40
|
const { tag, quasi: { quasis, expressions } } = path.node;
|
@@ -99,7 +99,9 @@ var index = helperPluginUtils.declare((_, { schema, development, queries = queri
|
|
99
99
|
throw path.buildCodeFrameError(errors[0].message);
|
100
100
|
}
|
101
101
|
query = graphql.stripIgnoredCharacters(query);
|
102
|
-
queries.
|
102
|
+
if (!development && !queries.includes(query)) {
|
103
|
+
queries.push(query);
|
104
|
+
}
|
103
105
|
const id = development ? query : hash(query);
|
104
106
|
const properties = [
|
105
107
|
core.types.objectProperty(core.types.identifier("query"), core.types.stringLiteral(id))
|
package/dist/index.js
CHANGED
@@ -19,19 +19,19 @@ var index = declare((_, { schema, development, queries = queriesCache })=>{
|
|
19
19
|
return {
|
20
20
|
name: "babel-plugin-graphql-tagged-template",
|
21
21
|
visitor: {
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
22
|
+
...development ? {} : {
|
23
|
+
VariableDeclarator (path, { filename = "" }) {
|
24
|
+
if (!(queriesPaths.includes(filename) && path.get("id").isIdentifier({
|
25
|
+
name: "queries"
|
26
|
+
}) && path.get("init").isObjectExpression())) {
|
27
|
+
return;
|
28
|
+
}
|
29
|
+
path.get("init").replaceWith(types.objectExpression(queries.sort().map((query)=>types.objectProperty(types.identifier(hash(query)), types.callExpression(types.memberExpression(types.identifier("JSON"), types.identifier("parse")), [
|
30
|
+
types.stringLiteral(JSON.stringify(parse(query, {
|
31
|
+
noLocation: true
|
32
|
+
})))
|
33
|
+
])))));
|
27
34
|
}
|
28
|
-
path.get("init").replaceWith(types.objectExpression([
|
29
|
-
...new Set(queries)
|
30
|
-
].sort().map((query)=>types.objectProperty(types.identifier(hash(query)), types.callExpression(types.memberExpression(types.identifier("JSON"), types.identifier("parse")), [
|
31
|
-
types.stringLiteral(JSON.stringify(parse(query, {
|
32
|
-
noLocation: true
|
33
|
-
})))
|
34
|
-
])))));
|
35
35
|
},
|
36
36
|
TaggedTemplateExpression (path) {
|
37
37
|
const { tag, quasi: { quasis, expressions } } = path.node;
|
@@ -96,7 +96,9 @@ var index = declare((_, { schema, development, queries = queriesCache })=>{
|
|
96
96
|
throw path.buildCodeFrameError(errors[0].message);
|
97
97
|
}
|
98
98
|
query = stripIgnoredCharacters(query);
|
99
|
-
queries.
|
99
|
+
if (!development && !queries.includes(query)) {
|
100
|
+
queries.push(query);
|
101
|
+
}
|
100
102
|
const id = development ? query : hash(query);
|
101
103
|
const properties = [
|
102
104
|
types.objectProperty(types.identifier("query"), types.stringLiteral(id))
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@mo36924/babel-plugin-graphql-tagged-template",
|
3
3
|
"type": "module",
|
4
|
-
"version": "5.0
|
4
|
+
"version": "5.1.0",
|
5
5
|
"description": "babel-plugin-graphql-tagged-template",
|
6
6
|
"author": "mo36924",
|
7
7
|
"license": "MIT",
|
@@ -54,5 +54,5 @@
|
|
54
54
|
"base-x": "^5.0.0",
|
55
55
|
"graphql": "^16.9.0"
|
56
56
|
},
|
57
|
-
"gitHead": "
|
57
|
+
"gitHead": "ea78ce7e8fdbd686f9ef572f939d3fee1bcbd5e9"
|
58
58
|
}
|