@mo36924/babel-plugin-graphql-tagged-template 5.4.3 → 5.4.4

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.cjs CHANGED
@@ -2,10 +2,12 @@
2
2
 
3
3
  var node_crypto = require('node:crypto');
4
4
  var node_path = require('node:path');
5
+ var node_process = require('node:process');
5
6
  var node_url = require('node:url');
6
7
  var core = require('@babel/core');
7
8
  var helperPluginUtils = require('@babel/helper-plugin-utils');
8
9
  var utils = require('@graphql-tools/utils');
10
+ var graphql$1 = require('@mo36924/graphql');
9
11
  var graphql = require('graphql');
10
12
  var packages_babelPluginGraphqlTaggedTemplate_dist_queries = require('./queries.cjs');
11
13
 
@@ -22,7 +24,7 @@ const schemaPaths = [
22
24
  "ts"
23
25
  ].map((extname)=>node_path.join(queriesDir, `schema.${extname}`));
24
26
  const hash = (data)=>node_crypto.createHash("sha256").update(data).digest("base64url");
25
- var index = helperPluginUtils.declare((_api, { schema, development, queries = packages_babelPluginGraphqlTaggedTemplate_dist_queries.queries })=>{
27
+ var index = helperPluginUtils.declare((_api, { development = node_process.env.NODE_ENV === "development", schema = graphql$1.getSchema().schema, queries = packages_babelPluginGraphqlTaggedTemplate_dist_queries.queries })=>{
26
28
  return {
27
29
  name: "babel-plugin-graphql-tagged-template",
28
30
  visitor: {
@@ -31,13 +33,14 @@ var index = helperPluginUtils.declare((_api, { schema, development, queries = pa
31
33
  if (queriesPaths.includes(filename) && path.get("id").isIdentifier({
32
34
  name: "queries"
33
35
  })) {
36
+ const sortedQueries = Object.fromEntries(Object.entries(queries).sort(([a], [b])=>a.localeCompare(b)));
34
37
  path.get("init").replaceWith(core.types.callExpression(core.types.memberExpression(core.types.identifier("Object"), core.types.identifier("assign")), [
35
38
  core.types.callExpression(core.types.memberExpression(core.types.identifier("Object"), core.types.identifier("create")), [
36
39
  core.types.nullLiteral()
37
40
  ]),
38
- core.types.objectExpression(Object.entries(queries).sort(([a], [b])=>a.localeCompare(b)).map(([key, documentNode])=>core.types.objectProperty(core.types.stringLiteral(key), core.types.callExpression(core.types.memberExpression(core.types.identifier("JSON"), core.types.identifier("parse")), [
39
- core.types.stringLiteral(JSON.stringify(documentNode))
40
- ]))))
41
+ core.types.callExpression(core.types.memberExpression(core.types.identifier("JSON"), core.types.identifier("parse")), [
42
+ core.types.stringLiteral(JSON.stringify(sortedQueries))
43
+ ])
41
44
  ]));
42
45
  } else if (schemaPaths.includes(filename) && path.get("id").isIdentifier({
43
46
  name: "schema"
package/dist/index.d.ts CHANGED
@@ -4,8 +4,8 @@ import { GraphQLSchema } from 'graphql';
4
4
  import { Queries } from './queries.js';
5
5
 
6
6
  type Options = {
7
- schema: GraphQLSchema;
8
7
  development?: boolean;
8
+ schema?: GraphQLSchema;
9
9
  queries?: Queries;
10
10
  };
11
11
  declare const _default: (api: object, options: Options | null | undefined, dirname: string) => PluginObj<_babel_core.PluginPass>;
package/dist/index.js CHANGED
@@ -1,9 +1,11 @@
1
1
  import { createHash } from 'node:crypto';
2
2
  import { dirname, join } from 'node:path';
3
+ import { env } from 'node:process';
3
4
  import { fileURLToPath } from 'node:url';
4
5
  import { types } from '@babel/core';
5
6
  import { declare } from '@babel/helper-plugin-utils';
6
7
  import { printSchemaWithDirectives } from '@graphql-tools/utils';
8
+ import { getSchema } from '@mo36924/graphql';
7
9
  import { parse, TypeInfo, OperationTypeNode, visit, visitWithTypeInfo, validate, stripIgnoredCharacters } from 'graphql';
8
10
  import { queries } from './queries.js';
9
11
 
@@ -19,7 +21,7 @@ const schemaPaths = [
19
21
  "ts"
20
22
  ].map((extname)=>join(queriesDir, `schema.${extname}`));
21
23
  const hash = (data)=>createHash("sha256").update(data).digest("base64url");
22
- var index = declare((_api, { schema, development, queries: queries$1 = queries })=>{
24
+ var index = declare((_api, { development = env.NODE_ENV === "development", schema = getSchema().schema, queries: queries$1 = queries })=>{
23
25
  return {
24
26
  name: "babel-plugin-graphql-tagged-template",
25
27
  visitor: {
@@ -28,13 +30,14 @@ var index = declare((_api, { schema, development, queries: queries$1 = queries }
28
30
  if (queriesPaths.includes(filename) && path.get("id").isIdentifier({
29
31
  name: "queries"
30
32
  })) {
33
+ const sortedQueries = Object.fromEntries(Object.entries(queries$1).sort(([a], [b])=>a.localeCompare(b)));
31
34
  path.get("init").replaceWith(types.callExpression(types.memberExpression(types.identifier("Object"), types.identifier("assign")), [
32
35
  types.callExpression(types.memberExpression(types.identifier("Object"), types.identifier("create")), [
33
36
  types.nullLiteral()
34
37
  ]),
35
- types.objectExpression(Object.entries(queries$1).sort(([a], [b])=>a.localeCompare(b)).map(([key, documentNode])=>types.objectProperty(types.stringLiteral(key), types.callExpression(types.memberExpression(types.identifier("JSON"), types.identifier("parse")), [
36
- types.stringLiteral(JSON.stringify(documentNode))
37
- ]))))
38
+ types.callExpression(types.memberExpression(types.identifier("JSON"), types.identifier("parse")), [
39
+ types.stringLiteral(JSON.stringify(sortedQueries))
40
+ ])
38
41
  ]));
39
42
  } else if (schemaPaths.includes(filename) && path.get("id").isIdentifier({
40
43
  name: "schema"
package/dist/schema.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var config = require('@mo36924/graphql/config');
3
+ var graphql = require('@mo36924/graphql');
4
4
 
5
- const schema = config.getSchema().schema;
5
+ const schema = graphql.getSchema().schema;
6
6
 
7
7
  exports.schema = schema;
package/dist/schema.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as graphql from 'graphql';
2
2
 
3
- declare const schema: graphql.GraphQLSchema | undefined;
3
+ declare const schema: graphql.GraphQLSchema;
4
4
 
5
5
  export { schema };
package/dist/schema.js CHANGED
@@ -1,4 +1,4 @@
1
- import { getSchema } from '@mo36924/graphql/config';
1
+ import { getSchema } from '@mo36924/graphql';
2
2
 
3
3
  const schema = getSchema().schema;
4
4
 
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.4.3",
4
+ "version": "5.4.4",
5
5
  "description": "babel-plugin-graphql-tagged-template",
6
6
  "author": "mo36924",
7
7
  "license": "MIT",
@@ -56,10 +56,10 @@
56
56
  "@babel/core": "^7.26.0",
57
57
  "@babel/helper-plugin-utils": "^7.25.9",
58
58
  "@graphql-tools/utils": "^10.5.6",
59
- "@mo36924/graphql": "^5.4.2",
59
+ "@mo36924/graphql": "^5.4.4",
60
60
  "@types/babel__core": "^7.20.5",
61
61
  "@types/babel__helper-plugin-utils": "^7.10.3",
62
62
  "graphql": "^16.9.0"
63
63
  },
64
- "gitHead": "e313716c27a4a0550a2e2b06506fbef0558bd0af"
64
+ "gitHead": "d441e61abb10c23ade3abb7217a9044e15fe767c"
65
65
  }