vite-plugin-graphql-loader 3.0.0 → 4.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.
package/README.md CHANGED
@@ -3,10 +3,13 @@
3
3
  [![NPM](https://nodei.co/npm/vite-plugin-graphql-loader.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/vite-plugin-graphql-loader/)
4
4
 
5
5
  [![npm version](https://img.shields.io/npm/v/vite-plugin-graphql-loader.svg)](https://www.npmjs.com/package/vite-plugin-graphql-loader)
6
+ ![Tag: Vite Plugin](https://img.shields.io/badge/Vite_Plugin-orange)
7
+ ![Tag: GraphQL](https://img.shields.io/badge/GraphQL-orange)
8
+ ![Tag: JavaScript](https://img.shields.io/badge/JavaScript-orange)
6
9
 
7
10
  A Vite plugin for loading GraphQL .gql and .graphql files, based on [graphql-tag/loader](https://github.com/apollographql/graphql-tag)
8
11
 
9
- If you are using TypeScript, I recommend using GraphQL Codegen and [vite-plugin-graphql-codegen](https://www.npmjs.com/package/vite-plugin-graphql-codegen) instead to generate TypesScript interfaces for your queries and fragments.
12
+ This package _doesn't_ generate TypeScript definitions from the queries and fragments - see [vite-plugin-graphql-codegen](https://www.npmjs.com/package/vite-plugin-graphql-codegen) if you require this.
10
13
 
11
14
  ## Install
12
15
 
@@ -56,21 +59,60 @@ query ExampleQuery {
56
59
  import ExampleQuery, { ExampleFragment } from "./example.graphql";
57
60
  ```
58
61
 
59
- If you are using TypeScript, you will have to declare `.gql` or `.graphql` files:
62
+ If you have multiple queries in the same file, import them like this:
60
63
 
61
- `graphql.d.ts`:
64
+ ```javascript
65
+ import { FirstQuery, SecondQuery } from "./example.graphql";
66
+ ```
67
+
68
+ ## TypeScript
69
+
70
+ If you are using TypeScript, you will have to declare `.gql` or `.graphql` files.
71
+
72
+ Create `graphql.d.ts` anywhere in your source directory and
62
73
 
63
74
  ```typescript
64
75
  declare module "*.gql";
65
76
  declare module "*.graphql";
77
+ ```
78
+
79
+ **_Alternatively_**, change it to this (replacing .gql with .graphql depending on what you use):
80
+
81
+ ```typescript
82
+ declare module "*.gql" {
83
+ const Query: import("graphql").DocumentNode;
84
+ export default Query;
85
+ export const _queries: Record<string, import("graphql").DocumentNode>;
86
+ export const _fragments: Record<
87
+ string,
88
+ import("graphql").FragmentDefinitionNode
89
+ >;
90
+ }
91
+ ```
92
+
93
+ And then import fragments and queries like so in order to type them as `DocumentNode` and `FragmentDefinitionNode` objects.
66
94
 
67
- // Or if you aren't using fragments:
68
- // declare module "*.gql" {
69
- // const Query: import("graphql").DocumentNode;
70
- // export default Query;
71
- // }
95
+ ```typescript
96
+ import Document, { _queries, _fragments } from "./example.graphql";
97
+ console.log(Document); // Has type `DocumentNode`
98
+ console.log(_queries.ExampleQuery); // Has type `DocumentNode`
99
+ console.log(_fragments.ExampleFragment); // Has type `FragmentDefinitionNode`
72
100
  ```
73
101
 
74
102
  ## Changelog
75
103
 
76
- **_v3.0.0_**: Moved from CJS to ESM, inline with Vite 5.0's CJS deprecation. If you are using CommonJS, continue using v2.0 of this package.
104
+ **_v4.0.0_**:
105
+
106
+ - Added source-map generation. Can by disabled by initializing with `graphqlLoader({noSourceMap: true})`.
107
+ - Refactored code generation to be more maintainable, added more test cases.
108
+ - Migrated from `yarn` to `bun`.
109
+
110
+ **_v3.0.1_**:
111
+
112
+ - Switched `await import` statements to top-level `import` statements (fixes #5 - `Top-level await is not available` error).
113
+ - Added `_queries` and `_fragments` for improved module declaration types.
114
+ - Updated snippets to be defined in TypeScript and then stringified.
115
+
116
+ **_v3.0.0_**:
117
+
118
+ - [Moved from CJS to ESM](https://github.com/noiach/vite-plugin-graphql-loader/commit/0e0b37cfcb0ecbdf28e985aeca3454137b4b73e3), inline with Vite 5.0's CJS deprecation. If you are using CommonJS, continue using v2.0 of this package. If you have `"type": "module"`, in your `package.json` then it should work as expected.
package/dist/index.d.ts CHANGED
@@ -1,9 +1,13 @@
1
- declare module "*.graphql";
2
- declare module "*.gql";
3
- export declare const vitePluginGraphqlLoader: () => {
1
+ import { SourceMap } from "magic-string";
2
+ export declare const vitePluginGraphqlLoader: (options?: {
3
+ noSourceMap?: boolean;
4
+ }) => {
4
5
  name: string;
5
6
  enforce: "pre";
6
- transform(source: string, id: string): string;
7
+ transform(source: string, id: string): {
8
+ code: string;
9
+ map: SourceMap;
10
+ };
7
11
  };
8
12
  export default vitePluginGraphqlLoader;
9
13
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,QAAQ,WAAW,CAAC;AAC3B,OAAO,QAAQ,OAAO,CAAC;AAwBvB,eAAO,MAAM,uBAAuB;;;sBAOV,MAAM,MAAM,MAAM;CAoE3C,CAAC;AAEF,eAAe,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAoB,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAkDtD,eAAO,MAAM,uBAAuB,aAAc;IAC9C,WAAW,CAAC,EAAE,OAAO,CAAC;CACzB;;;sBAUyB,MAAM,MAAM,MAAM;;;;CAgI3C,CAAC;AAEF,eAAe,uBAAuB,CAAC"}
package/dist/index.js CHANGED
@@ -1,22 +1,30 @@
1
1
  import { EOL } from "os";
2
2
  import { gql } from "graphql-tag";
3
- import { ONE_QUERY, UNIQUE } from "./snippets.js";
3
+ import MagicString from "magic-string";
4
+ import { vitePluginGraphqlLoaderUniqueChecker, vitePluginGraphqlLoaderExtractQuery, } from "./snippets.js";
5
+ const DOC_NAME = "_gql_doc";
4
6
  const expandImports = (source) => {
5
7
  const lines = source.split(/\r\n|\r|\n/);
6
- let outputCode = UNIQUE;
8
+ const importNames = new Set();
9
+ const imports = [];
10
+ const importAppends = [];
7
11
  lines.some((line) => {
8
12
  const result = line.match(/^#\s?import (.+)$/);
9
13
  if (result) {
10
14
  const [_, importFile] = result;
11
- const parseDocument = `(await import(${importFile})).default`;
12
- const appendDefinition = `doc.definitions = doc.definitions.concat(unique(${parseDocument}.definitions));`;
13
- outputCode += appendDefinition + EOL;
15
+ let importName = "Import_" + importFile.replace(/[^a-z0-9]/gi, "_");
16
+ while (importNames.has(importName)) {
17
+ importName = importName + "_";
18
+ }
19
+ importNames.add(importName);
20
+ imports.push(`import ${importName} from ${importFile};\n`);
21
+ importAppends.push(`${DOC_NAME}.definitions = ${DOC_NAME}.definitions.concat(${vitePluginGraphqlLoaderUniqueChecker.name}(${importName}.definitions));\n`);
14
22
  }
15
- return line.length > 0 && line[0] !== "#";
23
+ return line.length !== 0 && line[0] !== "#";
16
24
  });
17
- return outputCode;
25
+ return { imports, importAppends };
18
26
  };
19
- export const vitePluginGraphqlLoader = () => {
27
+ export const vitePluginGraphqlLoader = (options) => {
20
28
  const graphqlRegex = /\.(?:gql|graphql)$/;
21
29
  return {
22
30
  name: "graphql-loader",
@@ -25,28 +33,46 @@ export const vitePluginGraphqlLoader = () => {
25
33
  if (!graphqlRegex.test(id)) {
26
34
  return;
27
35
  }
28
- const documentNode = gql `
29
- ${source}
30
- `;
31
- const headerCode = `
32
- const doc = ${JSON.stringify(documentNode)};
33
- doc.loc.source = ${JSON.stringify(documentNode.loc.source)};
34
- `;
35
- let outputCode = "";
36
- const operationCount = documentNode.definitions.reduce((accum, op) => {
37
- if (op.kind === "OperationDefinition" ||
38
- op.kind === "FragmentDefinition") {
39
- return accum + 1;
40
- }
41
- return accum;
42
- }, 0);
43
- if (operationCount < 1) {
44
- outputCode += `
45
- export default doc;
46
- `;
36
+ let documentNode;
37
+ try {
38
+ documentNode = gql `
39
+ ${source}
40
+ `;
41
+ }
42
+ catch (error) {
43
+ throw new Error(String(error));
44
+ }
45
+ let outputCode = new MagicString(source).replaceAll("`", "\\`");
46
+ outputCode.prepend(`const _gql_source = \``);
47
+ outputCode.append(`\`;\n`);
48
+ const plainDocument = Object.assign({}, documentNode);
49
+ Object.assign(plainDocument.loc, documentNode.loc);
50
+ const documentObject = JSON.parse(JSON.stringify(documentNode));
51
+ const sourceBodyIdentifier = `_gql_uuid_${new Date().getTime()}`;
52
+ if (documentNode.loc && documentNode.loc.source) {
53
+ documentObject.loc.source = {
54
+ name: documentNode.loc.source.name,
55
+ locationOffset: documentNode.loc.source.locationOffset,
56
+ body: sourceBodyIdentifier,
57
+ };
47
58
  }
48
- else {
49
- outputCode += ONE_QUERY;
59
+ outputCode.append(`const ${DOC_NAME} = ${JSON.stringify(documentObject).replace(`"${sourceBodyIdentifier}"`, "_gql_source")};\n`);
60
+ const { imports, importAppends } = expandImports(source);
61
+ if (imports.length) {
62
+ outputCode.prepend(imports.join(""));
63
+ outputCode.append(`const ${vitePluginGraphqlLoaderUniqueChecker.name} = ${vitePluginGraphqlLoaderUniqueChecker.toString()};\n`);
64
+ outputCode.append(importAppends.join(""));
65
+ }
66
+ const operationCount = documentNode.definitions.filter((op) => (op.kind === "OperationDefinition" ||
67
+ op.kind === "FragmentDefinition") &&
68
+ op.name).length;
69
+ const queryNames = [];
70
+ const fragmentNames = [];
71
+ if (operationCount >= 1) {
72
+ const extractQueries = operationCount > 1 || imports.length > 0;
73
+ if (extractQueries) {
74
+ outputCode.append(`const ${vitePluginGraphqlLoaderExtractQuery.name} = ${vitePluginGraphqlLoaderExtractQuery.toString()};\n`);
75
+ }
50
76
  for (const op of documentNode.definitions) {
51
77
  if (op.kind === "OperationDefinition" ||
52
78
  op.kind === "FragmentDefinition") {
@@ -59,15 +85,26 @@ doc.loc.source = ${JSON.stringify(documentNode.loc.source)};
59
85
  }
60
86
  }
61
87
  const opName = op.name.value;
62
- outputCode += `
63
- export const ${opName} = oneQuery(doc, "${opName}");
64
- `;
88
+ outputCode.append(`export const ${opName} = ${extractQueries ? `${vitePluginGraphqlLoaderExtractQuery.name}(${DOC_NAME}, "${opName}")` : DOC_NAME};\n`);
89
+ if (op.kind === "OperationDefinition") {
90
+ queryNames.push(opName);
91
+ }
92
+ else {
93
+ fragmentNames.push(opName);
94
+ }
65
95
  }
66
96
  }
67
97
  }
68
- const importOutputCode = expandImports(source);
69
- const allCode = headerCode + EOL + importOutputCode + EOL + outputCode + EOL;
70
- return allCode;
98
+ outputCode.append(`export const _queries = {${queryNames.join(",")}};\n`);
99
+ outputCode.append(`export const _fragments = {${fragmentNames.join(",")}};\n`);
100
+ outputCode.append(`export default ${DOC_NAME};\n`);
101
+ outputCode.replaceAll("\n", EOL);
102
+ return {
103
+ code: outputCode.toString(),
104
+ map: options?.noSourceMap
105
+ ? { mappings: "" }
106
+ : outputCode.generateMap(),
107
+ };
71
108
  },
72
109
  };
73
110
  };
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAQlD,MAAM,aAAa,GAAG,CAAC,MAAc,EAAE,EAAE;IACrC,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;IACzC,IAAI,UAAU,GAAG,MAAM,CAAC;IAExB,KAAK,CAAC,IAAI,CAAC,CAAC,IAAY,EAAE,EAAE;QACxB,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC;QAC/C,IAAI,MAAM,EAAE,CAAC;YACT,MAAM,CAAC,CAAC,EAAE,UAAU,CAAC,GAAG,MAAM,CAAC;YAC/B,MAAM,aAAa,GAAG,iBAAiB,UAAU,YAAY,CAAC;YAC9D,MAAM,gBAAgB,GAAG,mDAAmD,aAAa,iBAAiB,CAAC;YAC3G,UAAU,IAAI,gBAAgB,GAAG,GAAG,CAAC;QACzC,CAAC;QACD,OAAO,IAAI,CAAC,MAAM,GAAG,CAAC,IAAI,IAA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AgB,MAAM,MAAM,cAAc,CAAC,CAAC,CAAC,GAAG,mCAAmC,CAAC,IAAI,IAAI,QAAQ,MAAM,MAAM,IAAI,CAAC,CAAC,CAAC,QAAQ,KAAK,CACvI,CAAC;wBAEF,IAAI,EAAE,CAAC,IAAI,KAAK,qBAAqB,EAAE,CAAC;4BACpC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;wBAC5B,CAAC;6BAAM,CAAC;4BACJ,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;wBAC/B,CAAC;oBACL,CAAC;gBACL,CAAC;YACL,CAAC;YAED,UAAU,CAAC,MAAM,CACb,4BAA4B,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CACzD,CAAC;YACF,UAAU,CAAC,MAAM,CACb,8BAA8B,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAC9D,CAAC;YAEF,UAAU,CAAC,MAAM,CAAC,kBAAkB,QAAQ,KAAK,CAAC,CAAC;YAEnD,UAAU,CAAC,UAAU,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;YAEjC,OAAO;gBACH,IAAI,EAAE,UAAU,CAAC,QAAQ,EAAE;gBAC3B,GAAG,EAAE,OAAO,EAAE,WAAW;oBACrB,CAAC,CAAE,EAAE,QAAQ,EAAE,EAAE,EAAgB;oBACjC,CAAC,CAAC,UAAU,CAAC,WAAW,EAAE;aACjC,CAAC;QACN,CAAC;KACJ,CAAC;AACN,CAAC,CAAC;AAEF,eAAe,uBAAuB,CAAC"}
@@ -1,3 +1,6 @@
1
- export declare const UNIQUE = "\nconst names = {};\nfunction unique(defs) {\n return defs.filter(\n function(def) {\n if (def.kind !== 'FragmentDefinition') return true;\n const name = def.name.value\n if (names[name]) {\n return false;\n } else {\n names[name] = true;\n return true;\n }\n }\n )\n}\n";
2
- export declare const ONE_QUERY = "\n// Collect any fragment/type references from a node, adding them to the refs Set\nfunction collectFragmentReferences(node, refs) {\n if (node.kind === \"FragmentSpread\") {\n refs.add(node.name.value);\n } else if (node.kind === \"VariableDefinition\") {\n const type = node.type;\n if (type.kind === \"NamedType\") {\n refs.add(type.name.value);\n }\n }\n if (node.selectionSet) {\n node.selectionSet.selections.forEach(function(selection) {\n collectFragmentReferences(selection, refs);\n });\n }\n if (node.variableDefinitions) {\n node.variableDefinitions.forEach(function(def) {\n collectFragmentReferences(def, refs);\n });\n }\n if (node.definitions) {\n node.definitions.forEach(function(def) {\n collectFragmentReferences(def, refs);\n });\n }\n}\nconst definitionRefs = {};\n(function extractReferences() {\n doc.definitions.forEach(function(def) {\n if (def.name) {\n const refs = new Set();\n collectFragmentReferences(def, refs);\n definitionRefs[def.name.value] = refs;\n }\n });\n})();\nfunction findOperation(doc, name) {\n for (let i = 0; i < doc.definitions.length; i++) {\n const element = doc.definitions[i];\n if (element.name && element.name.value == name) {\n return element;\n }\n }\n}\nfunction oneQuery(doc, operationName) {\n // Copy the DocumentNode, but clear out the definitions\n const newDoc = {\n kind: doc.kind,\n definitions: [findOperation(doc, operationName)]\n };\n if (doc.hasOwnProperty(\"loc\")) {\n newDoc.loc = doc.loc;\n }\n // Now, for the operation we're running, find any fragments referenced by\n // it or the fragments it references\n const opRefs = definitionRefs[operationName] || new Set();\n const allRefs = new Set();\n let newRefs = new Set();\n // IE 11 doesn't support \"new Set(iterable)\", so we add the members of opRefs to newRefs one by one\n opRefs.forEach(function(refName) {\n newRefs.add(refName);\n });\n while (newRefs.size > 0) {\n const prevRefs = newRefs;\n newRefs = new Set();\n prevRefs.forEach(function(refName) {\n if (!allRefs.has(refName)) {\n allRefs.add(refName);\n const childRefs = definitionRefs[refName] || new Set();\n childRefs.forEach(function(childRef) {\n newRefs.add(childRef);\n });\n }\n });\n }\n allRefs.forEach(function(refName) {\n const op = findOperation(doc, refName);\n if (op) {\n newDoc.definitions.push(op);\n }\n });\n return newDoc;\n}\n\nexport default doc;\n";
1
+ import type { DefinitionNode, DocumentNode } from "graphql";
2
+ export declare const vitePluginGraphqlLoaderUniqueChecker: (defs: DefinitionNode[]) => DefinitionNode[];
3
+ export declare const vitePluginGraphqlLoaderExtractQuery: (doc: DocumentNode, operationName: string) => DocumentNode & {
4
+ definitions: (import("graphql").OperationDefinitionNode | import("graphql").FragmentDefinitionNode | import("graphql").ScalarTypeDefinitionNode | import("graphql").ObjectTypeDefinitionNode | import("graphql").InterfaceTypeDefinitionNode | import("graphql").UnionTypeDefinitionNode | import("graphql").EnumTypeDefinitionNode | import("graphql").InputObjectTypeDefinitionNode | import("graphql").DirectiveDefinitionNode | import("graphql").ScalarTypeExtensionNode | import("graphql").ObjectTypeExtensionNode | import("graphql").InterfaceTypeExtensionNode | import("graphql").UnionTypeExtensionNode | import("graphql").EnumTypeExtensionNode | import("graphql").InputObjectTypeExtensionNode)[];
5
+ };
3
6
  //# sourceMappingURL=snippets.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"snippets.d.ts","sourceRoot":"","sources":["../src/snippets.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,MAAM,yUAgBlB,CAAC;AAEF,eAAO,MAAM,SAAS,6gFAsFrB,CAAC"}
1
+ {"version":3,"file":"snippets.d.ts","sourceRoot":"","sources":["../src/snippets.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAW,cAAc,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAMrE,eAAO,MAAM,oCAAoC,SACvC,cAAc,EAAE,qBAazB,CAAC;AAEF,eAAO,MAAM,mCAAmC,QACvC,YAAY,iBACF,MAAM;;CAoGxB,CAAC"}
package/dist/snippets.js CHANGED
@@ -1,105 +1,95 @@
1
- export const UNIQUE = `
2
- const names = {};
3
- function unique(defs) {
4
- return defs.filter(
5
- function(def) {
6
- if (def.kind !== 'FragmentDefinition') return true;
7
- const name = def.name.value
8
- if (names[name]) {
9
- return false;
10
- } else {
11
- names[name] = true;
12
- return true;
13
- }
14
- }
15
- )
16
- }
17
- `;
18
- export const ONE_QUERY = `
19
- // Collect any fragment/type references from a node, adding them to the refs Set
20
- function collectFragmentReferences(node, refs) {
21
- if (node.kind === "FragmentSpread") {
22
- refs.add(node.name.value);
23
- } else if (node.kind === "VariableDefinition") {
24
- const type = node.type;
25
- if (type.kind === "NamedType") {
26
- refs.add(type.name.value);
27
- }
28
- }
29
- if (node.selectionSet) {
30
- node.selectionSet.selections.forEach(function(selection) {
31
- collectFragmentReferences(selection, refs);
1
+ export const vitePluginGraphqlLoaderUniqueChecker = (defs) => {
2
+ const names = {};
3
+ return defs.filter(function (def) {
4
+ if (def.kind !== "FragmentDefinition")
5
+ return true;
6
+ const name = def.name.value;
7
+ if (names[name]) {
8
+ return false;
9
+ }
10
+ else {
11
+ names[name] = true;
12
+ return true;
13
+ }
32
14
  });
33
- }
34
- if (node.variableDefinitions) {
35
- node.variableDefinitions.forEach(function(def) {
36
- collectFragmentReferences(def, refs);
15
+ };
16
+ export const vitePluginGraphqlLoaderExtractQuery = (doc, operationName) => {
17
+ const collectFragmentReferences = (node, refs) => {
18
+ if (node.kind === "FragmentSpread") {
19
+ refs.add(node.name.value);
20
+ }
21
+ else if (node.kind === "VariableDefinition") {
22
+ const type = node.type;
23
+ if (type.kind === "NamedType") {
24
+ refs.add(type.name.value);
25
+ }
26
+ }
27
+ if (node && "selectionSet" in node && node.selectionSet) {
28
+ node.selectionSet.selections.forEach((selection) => {
29
+ collectFragmentReferences(selection, refs);
30
+ });
31
+ }
32
+ if (node && "variableDefinitions" in node && node.variableDefinitions) {
33
+ node.variableDefinitions.forEach((def) => {
34
+ collectFragmentReferences(def, refs);
35
+ });
36
+ }
37
+ if (node && "definitions" in node && node.definitions) {
38
+ node.definitions.forEach((def) => {
39
+ collectFragmentReferences(def, refs);
40
+ });
41
+ }
42
+ return refs;
43
+ };
44
+ const extractReferences = (doc) => {
45
+ const definitionRefs = {};
46
+ doc.definitions.forEach(function (def) {
47
+ if ("name" in def && def.name) {
48
+ definitionRefs[def.name.value] = collectFragmentReferences(def, new Set());
49
+ }
50
+ });
51
+ return definitionRefs;
52
+ };
53
+ const findOperation = (doc, name) => {
54
+ for (let i = 0; i < doc.definitions.length; i++) {
55
+ const element = doc.definitions[i];
56
+ if (element &&
57
+ "name" in element &&
58
+ element.name &&
59
+ element.name.value == name) {
60
+ return element;
61
+ }
62
+ }
63
+ };
64
+ const definitionRefs = extractReferences(doc);
65
+ const newDoc = Object.assign({}, doc, {
66
+ definitions: [findOperation(doc, operationName)],
37
67
  });
38
- }
39
- if (node.definitions) {
40
- node.definitions.forEach(function(def) {
41
- collectFragmentReferences(def, refs);
68
+ const opRefs = definitionRefs[operationName] || new Set();
69
+ const allRefs = new Set();
70
+ let newRefs = new Set();
71
+ opRefs.forEach((refName) => {
72
+ newRefs.add(refName);
42
73
  });
43
- }
44
- }
45
- const definitionRefs = {};
46
- (function extractReferences() {
47
- doc.definitions.forEach(function(def) {
48
- if (def.name) {
49
- const refs = new Set();
50
- collectFragmentReferences(def, refs);
51
- definitionRefs[def.name.value] = refs;
52
- }
53
- });
54
- })();
55
- function findOperation(doc, name) {
56
- for (let i = 0; i < doc.definitions.length; i++) {
57
- const element = doc.definitions[i];
58
- if (element.name && element.name.value == name) {
59
- return element;
60
- }
61
- }
62
- }
63
- function oneQuery(doc, operationName) {
64
- // Copy the DocumentNode, but clear out the definitions
65
- const newDoc = {
66
- kind: doc.kind,
67
- definitions: [findOperation(doc, operationName)]
68
- };
69
- if (doc.hasOwnProperty("loc")) {
70
- newDoc.loc = doc.loc;
71
- }
72
- // Now, for the operation we're running, find any fragments referenced by
73
- // it or the fragments it references
74
- const opRefs = definitionRefs[operationName] || new Set();
75
- const allRefs = new Set();
76
- let newRefs = new Set();
77
- // IE 11 doesn't support "new Set(iterable)", so we add the members of opRefs to newRefs one by one
78
- opRefs.forEach(function(refName) {
79
- newRefs.add(refName);
80
- });
81
- while (newRefs.size > 0) {
82
- const prevRefs = newRefs;
83
- newRefs = new Set();
84
- prevRefs.forEach(function(refName) {
85
- if (!allRefs.has(refName)) {
86
- allRefs.add(refName);
87
- const childRefs = definitionRefs[refName] || new Set();
88
- childRefs.forEach(function(childRef) {
89
- newRefs.add(childRef);
74
+ while (newRefs.size > 0) {
75
+ const prevRefs = newRefs;
76
+ newRefs = new Set();
77
+ prevRefs.forEach((refName) => {
78
+ if (!allRefs.has(refName)) {
79
+ allRefs.add(refName);
80
+ const childRefs = definitionRefs[refName] || new Set();
81
+ childRefs.forEach((childRef) => {
82
+ newRefs.add(childRef);
83
+ });
84
+ }
90
85
  });
91
- }
92
- });
93
- }
94
- allRefs.forEach(function(refName) {
95
- const op = findOperation(doc, refName);
96
- if (op) {
97
- newDoc.definitions.push(op);
98
86
  }
99
- });
100
- return newDoc;
101
- }
102
-
103
- export default doc;
104
- `;
87
+ allRefs.forEach((refName) => {
88
+ const op = findOperation(doc, refName);
89
+ if (op) {
90
+ newDoc.definitions.push(op);
91
+ }
92
+ });
93
+ return newDoc;
94
+ };
105
95
  //# sourceMappingURL=snippets.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"snippets.js","sourceRoot":"","sources":["../src/snippets.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;CAgBrB,CAAC;AAEF,MAAM,CAAC,MAAM,SAAS,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsFxB,CAAC"}
1
+ {"version":3,"file":"snippets.js","sourceRoot":"","sources":["../src/snippets.ts"],"names":[],"mappings":"AAcA,MAAM,CAAC,MAAM,oCAAoC,GAAG,CAChD,IAAsB,EACxB,EAAE;IACA,MAAM,KAAK,GAAG,EAAE,CAAC;IACjB,OAAO,IAAI,CAAC,MAAM,CAAC,UAAU,GAAG;QAC5B,IAAI,GAAG,CAAC,IAAI,KAAK,oBAAoB;YAAE,OAAO,IAAI,CAAC;QACnD,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC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M,CAAC;AAClB,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-plugin-graphql-loader",
3
- "version": "3.0.0",
3
+ "version": "4.0.0",
4
4
  "description": "A Vite plugin for loading GraphQL files.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -34,12 +34,15 @@
34
34
  "homepage": "https://github.com/noiach/vite-plugin-graphql-loader#readme",
35
35
  "dependencies": {
36
36
  "graphql": "^16.8.1",
37
- "graphql-tag": "^2.12.6"
37
+ "graphql-tag": "^2.12.6",
38
+ "magic-string": "^0.30.10"
38
39
  },
39
40
  "devDependencies": {
41
+ "@babel/parser": "^7.24.8",
42
+ "@babel/traverse": "^7.24.8",
43
+ "@types/babel__traverse": "^7.20.6",
40
44
  "@types/node": "^20",
41
45
  "eslint": "^8.56.0",
42
- "glob": "^10.3.10",
43
46
  "prettier": "^3.2.4",
44
47
  "rimraf": "^5.0.5",
45
48
  "typescript": "^5.3.3",