@graphitation/webpack-loader 1.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/CHANGELOG.md ADDED
@@ -0,0 +1,20 @@
1
+ # Change Log - @graphitation/webpack-loader
2
+
3
+ This log was last generated on Wed, 14 Feb 2024 20:38:06 GMT and should not be manually modified.
4
+
5
+ <!-- Start content -->
6
+
7
+ ## 1.0.0
8
+
9
+ Wed, 14 Feb 2024 20:38:06 GMT
10
+
11
+ ### Major changes
12
+
13
+ - Fork of graphql-tools/webpack-loader with supermassive encoding support for SDL (vladimir.razuvaev@gmail.com)
14
+ - Bump @graphitation/supermassive to v3.4.2
15
+
16
+ # @graphitation/webpack-loader
17
+
18
+ > See https://github.com/ardatan/graphql-tools/blob/master/packages/webpack-loader/CHANGELOG.md
19
+ >
20
+ > Forked version 7.0.0
package/NOTICE ADDED
@@ -0,0 +1,27 @@
1
+ NOTICES
2
+
3
+ This repository incorporates material as listed below or described in the code.
4
+
5
+ @graphql-tools/webpack-loader
6
+
7
+ The MIT License (MIT)
8
+
9
+ Copyright (c) 2020 The Guild, Inc.
10
+
11
+ Permission is hereby granted, free of charge, to any person obtaining a copy
12
+ of this software and associated documentation files (the "Software"), to deal
13
+ in the Software without restriction, including without limitation the rights
14
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
+ copies of the Software, and to permit persons to whom the Software is
16
+ furnished to do so, subject to the following conditions:
17
+
18
+ The above copyright notice and this permission notice shall be included in all
19
+ copies or substantial portions of the Software.
20
+
21
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,63 @@
1
+ # A fork of GraphQL Tools Webpack Loader
2
+
3
+ > A fork of `@graphql-tools/webpack-loader` with supermassive SDL encoding support
4
+
5
+ A webpack loader to preprocess GraphQL Documents (operations, fragments and SDL)
6
+
7
+ yarn add @graphitation/webpack-loader
8
+
9
+ How is it different from `graphql-tag`? It removes locations entirely, doesn't include sources
10
+ (string content of imported files), no warnings about duplicated fragment names and supports more
11
+ custom scenarios.
12
+
13
+ ## Options
14
+
15
+ - noDescription (_default: false_) - removes descriptions
16
+ - esModule (_default: false_) - uses import and export statements instead of CommonJS
17
+ - supermassiveSDL (_default: false_) - encode SDL for execution with [supermassive](../supermassive)
18
+
19
+ ## Importing GraphQL files
20
+
21
+ _To add support for importing `.graphql`/`.gql` files, see
22
+ [Webpack loading and preprocessing](#webpack-loading-and-preprocessing) below._
23
+
24
+ Given a file `MyQuery.graphql`
25
+
26
+ ```graphql
27
+ query MyQuery {
28
+ ...
29
+ }
30
+ ```
31
+
32
+ If you have configured
33
+ [the webpack @graphitation/webpack-loader](#webpack-loading-and-preprocessing), you can import
34
+ modules containing graphQL queries. The imported value will be the pre-built AST.
35
+
36
+ ```ts
37
+ import MyQuery from "./query.graphql";
38
+ ```
39
+
40
+ ### Preprocessing queries and fragments
41
+
42
+ Preprocessing GraphQL queries and fragments into ASTs at build time can greatly improve load times.
43
+
44
+ #### Webpack loading and preprocessing
45
+
46
+ Using the included `@graphitation/webpack-loader` it is possible to maintain query logic that is
47
+ separate from the rest of your application logic. With the loader configured, imported graphQL files
48
+ will be converted to AST during the webpack build process.
49
+
50
+ ```js
51
+ {
52
+ loaders: [
53
+ {
54
+ test: /\.(graphql|gql)$/,
55
+ exclude: /node_modules/,
56
+ loader: '@graphitation/webpack-loader',
57
+ options: {
58
+ /* ... */
59
+ }
60
+ }
61
+ ],
62
+ }
63
+ ```
package/lib/index.d.ts ADDED
@@ -0,0 +1,13 @@
1
+ import type { LoaderContext } from "webpack";
2
+ interface Options {
3
+ noDescription?: boolean;
4
+ noEmptyNodes?: boolean;
5
+ noLoc?: boolean;
6
+ replaceKinds?: boolean;
7
+ esModule?: boolean;
8
+ importHelpers?: boolean;
9
+ supermassiveSDL?: boolean;
10
+ }
11
+ export default function graphqlLoader(this: LoaderContext<Options>, source: string): string;
12
+ export {};
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAc7C,UAAU,OAAO;IACf,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAwBD,MAAM,CAAC,OAAO,UAAU,aAAa,CACnC,IAAI,EAAE,aAAa,CAAC,OAAO,CAAC,EAC5B,MAAM,EAAE,MAAM,UA2Ef"}
package/lib/index.js ADDED
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var src_exports = {};
20
+ __export(src_exports, {
21
+ default: () => graphqlLoader
22
+ });
23
+ module.exports = __toCommonJS(src_exports);
24
+ var import_graphql = require("graphql");
25
+ var import_optimize = require("@graphql-tools/optimize");
26
+ var import_webpack_loader_runtime = require("@graphql-tools/webpack-loader-runtime");
27
+ var import_supermassive = require("@graphitation/supermassive");
28
+ var import_parser = require("./parser");
29
+ function isSDL(doc) {
30
+ return !doc.definitions.some((def) => (0, import_graphql.isExecutableDefinitionNode)(def));
31
+ }
32
+ function expandImports(source, options) {
33
+ const lines = source.trim().split(/[\r\n]+/);
34
+ const outputHeader = options.importHelpers ? `
35
+ var useUnique = require('@graphql-tools/webpack-loader-runtime').useUnique;
36
+ var unique = useUnique();` : `${import_webpack_loader_runtime.uniqueCode}`;
37
+ let outputCode = ``;
38
+ lines.some((line) => {
39
+ if (line[0] === "#" && line.slice(1).split(" ")[0] === "import") {
40
+ const importFile = line.slice(1).split(" ")[1];
41
+ const parseDocument2 = `require(${importFile})`;
42
+ const appendDef = `doc.definitions = doc.definitions.concat(unique(${parseDocument2}.definitions));`;
43
+ outputCode += appendDef + "\n";
44
+ }
45
+ return line.length !== 0 && line[0] !== "#";
46
+ });
47
+ return outputCode.trim().length > 0 ? outputHeader + "\n" + outputCode : ``;
48
+ }
49
+ function graphqlLoader(source) {
50
+ this.cacheable();
51
+ const options = this.query || {};
52
+ let doc = (0, import_parser.parseDocument)(source);
53
+ const optimizers = [];
54
+ if (options.noDescription) {
55
+ optimizers.push(import_optimize.removeDescriptions);
56
+ }
57
+ if (options.noEmptyNodes) {
58
+ optimizers.push(import_optimize.removeEmptyNodes);
59
+ }
60
+ if (optimizers.length > 0 && isSDL(doc)) {
61
+ doc = (0, import_optimize.optimizeDocumentNode)(doc, optimizers);
62
+ }
63
+ let stringifiedDoc = ``;
64
+ if (options.supermassiveSDL && isSDL(doc)) {
65
+ stringifiedDoc = JSON.stringify((0, import_supermassive.encodeASTSchema)(doc));
66
+ } else {
67
+ stringifiedDoc = JSON.stringify(doc);
68
+ if (options.replaceKinds) {
69
+ for (const identifier in import_graphql.Kind) {
70
+ const value = import_graphql.Kind[identifier];
71
+ stringifiedDoc = stringifiedDoc.replace(
72
+ new RegExp(`"kind":"${value}"`, "g"),
73
+ `"kind": Kind.${identifier}`
74
+ );
75
+ }
76
+ }
77
+ }
78
+ const headerCode = [
79
+ options.replaceKinds ? "var Kind = require('graphql/language/kinds');" : "",
80
+ // See https://v8.dev/blog/cost-of-javascript-2019#json
81
+ `var doc = JSON.parse('${stringifiedDoc}');`
82
+ ].join("\n");
83
+ let outputCode = "";
84
+ const operationCount = doc.definitions.reduce((accum, op) => {
85
+ if (op.kind === import_graphql.Kind.OPERATION_DEFINITION) {
86
+ return accum + 1;
87
+ }
88
+ return accum;
89
+ }, 0);
90
+ function exportDefaultStatement(identifier) {
91
+ if (options.esModule) {
92
+ return `export default ${identifier}`;
93
+ }
94
+ return `module.exports = ${identifier}`;
95
+ }
96
+ if (operationCount > 1) {
97
+ throw new Error(
98
+ "GraphQL Webpack Loader allows only for one GraphQL Operation per file"
99
+ );
100
+ }
101
+ outputCode += `${exportDefaultStatement("doc")}`;
102
+ const importOutputCode = expandImports(source, options);
103
+ const allCode = [headerCode, importOutputCode, outputCode, ""].join("\n");
104
+ return allCode;
105
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/index.ts"],
4
+ "sourcesContent": ["import { DocumentNode, isExecutableDefinitionNode, Kind } from \"graphql\";\nimport type { LoaderContext } from \"webpack\";\nimport {\n optimizeDocumentNode,\n removeDescriptions,\n removeEmptyNodes,\n} from \"@graphql-tools/optimize\";\nimport { uniqueCode } from \"@graphql-tools/webpack-loader-runtime\";\nimport { encodeASTSchema } from \"@graphitation/supermassive\";\nimport { parseDocument } from \"./parser\";\n\nfunction isSDL(doc: DocumentNode) {\n return !doc.definitions.some((def) => isExecutableDefinitionNode(def));\n}\n\ninterface Options {\n noDescription?: boolean;\n noEmptyNodes?: boolean;\n noLoc?: boolean;\n replaceKinds?: boolean;\n esModule?: boolean;\n importHelpers?: boolean;\n supermassiveSDL?: boolean;\n}\n\nfunction expandImports(source: string, options: Options) {\n const lines = source.trim().split(/[\\r\\n]+/);\n const outputHeader = options.importHelpers\n ? `\nvar useUnique = require('@graphql-tools/webpack-loader-runtime').useUnique;\nvar unique = useUnique();`\n : `${uniqueCode}`;\n\n let outputCode = ``;\n lines.some((line) => {\n if (line[0] === \"#\" && line.slice(1).split(\" \")[0] === \"import\") {\n const importFile = line.slice(1).split(\" \")[1];\n const parseDocument = `require(${importFile})`;\n const appendDef = `doc.definitions = doc.definitions.concat(unique(${parseDocument}.definitions));`;\n outputCode += appendDef + \"\\n\";\n }\n return line.length !== 0 && line[0] !== \"#\";\n });\n\n return outputCode.trim().length > 0 ? outputHeader + \"\\n\" + outputCode : ``;\n}\n\nexport default function graphqlLoader(\n this: LoaderContext<Options>,\n source: string,\n) {\n this.cacheable();\n // TODO: This should probably use this.getOptions()\n const options = (this.query as Options) || {};\n let doc = parseDocument(source);\n\n const optimizers = [];\n\n if (options.noDescription) {\n optimizers.push(removeDescriptions);\n }\n if (options.noEmptyNodes) {\n optimizers.push(removeEmptyNodes);\n }\n\n if (optimizers.length > 0 && isSDL(doc)) {\n doc = optimizeDocumentNode(doc, optimizers);\n }\n\n let stringifiedDoc = ``;\n if (options.supermassiveSDL && isSDL(doc)) {\n stringifiedDoc = JSON.stringify(encodeASTSchema(doc));\n } else {\n stringifiedDoc = JSON.stringify(doc);\n if (options.replaceKinds) {\n for (const identifier in Kind) {\n const value = Kind[identifier as keyof typeof Kind];\n stringifiedDoc = stringifiedDoc.replace(\n new RegExp(`\"kind\":\"${value}\"`, \"g\"),\n `\"kind\": Kind.${identifier}`,\n );\n }\n }\n }\n\n const headerCode = [\n options.replaceKinds ? \"var Kind = require('graphql/language/kinds');\" : \"\",\n // See https://v8.dev/blog/cost-of-javascript-2019#json\n `var doc = JSON.parse('${stringifiedDoc}');`,\n ].join(\"\\n\");\n\n let outputCode = \"\";\n\n // Allow multiple query/mutation definitions in a file. This parses out dependencies\n // at compile time, and then uses those at load time to create minimal query documents\n // We cannot do the latter at compile time due to how the #import code works.\n const operationCount = doc.definitions.reduce<number>((accum, op) => {\n if (op.kind === Kind.OPERATION_DEFINITION) {\n return accum + 1;\n }\n\n return accum;\n }, 0);\n\n function exportDefaultStatement(identifier: string) {\n if (options.esModule) {\n return `export default ${identifier}`;\n }\n\n return `module.exports = ${identifier}`;\n }\n\n if (operationCount > 1) {\n throw new Error(\n \"GraphQL Webpack Loader allows only for one GraphQL Operation per file\",\n );\n }\n\n outputCode += `${exportDefaultStatement(\"doc\")}`;\n\n const importOutputCode = expandImports(source, options);\n const allCode = [headerCode, importOutputCode, outputCode, \"\"].join(\"\\n\");\n\n return allCode;\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAA+D;AAE/D,sBAIO;AACP,oCAA2B;AAC3B,0BAAgC;AAChC,oBAA8B;AAE9B,SAAS,MAAM,KAAmB;AAChC,SAAO,CAAC,IAAI,YAAY,KAAK,CAAC,YAAQ,2CAA2B,GAAG,CAAC;AACvE;AAYA,SAAS,cAAc,QAAgB,SAAkB;AACvD,QAAM,QAAQ,OAAO,KAAK,EAAE,MAAM,SAAS;AAC3C,QAAM,eAAe,QAAQ,gBACzB;AAAA;AAAA,6BAGA,GAAG;AAEP,MAAI,aAAa;AACjB,QAAM,KAAK,CAAC,SAAS;AACnB,QAAI,KAAK,CAAC,MAAM,OAAO,KAAK,MAAM,CAAC,EAAE,MAAM,GAAG,EAAE,CAAC,MAAM,UAAU;AAC/D,YAAM,aAAa,KAAK,MAAM,CAAC,EAAE,MAAM,GAAG,EAAE,CAAC;AAC7C,YAAMA,iBAAgB,WAAW;AACjC,YAAM,YAAY,mDAAmDA;AACrE,oBAAc,YAAY;AAAA,IAC5B;AACA,WAAO,KAAK,WAAW,KAAK,KAAK,CAAC,MAAM;AAAA,EAC1C,CAAC;AAED,SAAO,WAAW,KAAK,EAAE,SAAS,IAAI,eAAe,OAAO,aAAa;AAC3E;AAEe,SAAR,cAEL,QACA;AACA,OAAK,UAAU;AAEf,QAAM,UAAW,KAAK,SAAqB,CAAC;AAC5C,MAAI,UAAM,6BAAc,MAAM;AAE9B,QAAM,aAAa,CAAC;AAEpB,MAAI,QAAQ,eAAe;AACzB,eAAW,KAAK,kCAAkB;AAAA,EACpC;AACA,MAAI,QAAQ,cAAc;AACxB,eAAW,KAAK,gCAAgB;AAAA,EAClC;AAEA,MAAI,WAAW,SAAS,KAAK,MAAM,GAAG,GAAG;AACvC,cAAM,sCAAqB,KAAK,UAAU;AAAA,EAC5C;AAEA,MAAI,iBAAiB;AACrB,MAAI,QAAQ,mBAAmB,MAAM,GAAG,GAAG;AACzC,qBAAiB,KAAK,cAAU,qCAAgB,GAAG,CAAC;AAAA,EACtD,OAAO;AACL,qBAAiB,KAAK,UAAU,GAAG;AACnC,QAAI,QAAQ,cAAc;AACxB,iBAAW,cAAc,qBAAM;AAC7B,cAAM,QAAQ,oBAAK,UAA+B;AAClD,yBAAiB,eAAe;AAAA,UAC9B,IAAI,OAAO,WAAW,UAAU,GAAG;AAAA,UACnC,gBAAgB;AAAA,QAClB;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,QAAM,aAAa;AAAA,IACjB,QAAQ,eAAe,kDAAkD;AAAA;AAAA,IAEzE,yBAAyB;AAAA,EAC3B,EAAE,KAAK,IAAI;AAEX,MAAI,aAAa;AAKjB,QAAM,iBAAiB,IAAI,YAAY,OAAe,CAAC,OAAO,OAAO;AACnE,QAAI,GAAG,SAAS,oBAAK,sBAAsB;AACzC,aAAO,QAAQ;AAAA,IACjB;AAEA,WAAO;AAAA,EACT,GAAG,CAAC;AAEJ,WAAS,uBAAuB,YAAoB;AAClD,QAAI,QAAQ,UAAU;AACpB,aAAO,kBAAkB;AAAA,IAC3B;AAEA,WAAO,oBAAoB;AAAA,EAC7B;AAEA,MAAI,iBAAiB,GAAG;AACtB,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAEA,gBAAc,GAAG,uBAAuB,KAAK;AAE7C,QAAM,mBAAmB,cAAc,QAAQ,OAAO;AACtD,QAAM,UAAU,CAAC,YAAY,kBAAkB,YAAY,EAAE,EAAE,KAAK,IAAI;AAExE,SAAO;AACT;",
6
+ "names": ["parseDocument"]
7
+ }
package/lib/index.mjs ADDED
@@ -0,0 +1,90 @@
1
+ // src/index.ts
2
+ import { isExecutableDefinitionNode, Kind } from "graphql";
3
+ import {
4
+ optimizeDocumentNode,
5
+ removeDescriptions,
6
+ removeEmptyNodes
7
+ } from "@graphql-tools/optimize";
8
+ import { uniqueCode } from "@graphql-tools/webpack-loader-runtime";
9
+ import { encodeASTSchema } from "@graphitation/supermassive";
10
+ import { parseDocument } from "./parser.mjs";
11
+ function isSDL(doc) {
12
+ return !doc.definitions.some((def) => isExecutableDefinitionNode(def));
13
+ }
14
+ function expandImports(source, options) {
15
+ const lines = source.trim().split(/[\r\n]+/);
16
+ const outputHeader = options.importHelpers ? `
17
+ var useUnique = require('@graphql-tools/webpack-loader-runtime').useUnique;
18
+ var unique = useUnique();` : `${uniqueCode}`;
19
+ let outputCode = ``;
20
+ lines.some((line) => {
21
+ if (line[0] === "#" && line.slice(1).split(" ")[0] === "import") {
22
+ const importFile = line.slice(1).split(" ")[1];
23
+ const parseDocument2 = `require(${importFile})`;
24
+ const appendDef = `doc.definitions = doc.definitions.concat(unique(${parseDocument2}.definitions));`;
25
+ outputCode += appendDef + "\n";
26
+ }
27
+ return line.length !== 0 && line[0] !== "#";
28
+ });
29
+ return outputCode.trim().length > 0 ? outputHeader + "\n" + outputCode : ``;
30
+ }
31
+ function graphqlLoader(source) {
32
+ this.cacheable();
33
+ const options = this.query || {};
34
+ let doc = parseDocument(source);
35
+ const optimizers = [];
36
+ if (options.noDescription) {
37
+ optimizers.push(removeDescriptions);
38
+ }
39
+ if (options.noEmptyNodes) {
40
+ optimizers.push(removeEmptyNodes);
41
+ }
42
+ if (optimizers.length > 0 && isSDL(doc)) {
43
+ doc = optimizeDocumentNode(doc, optimizers);
44
+ }
45
+ let stringifiedDoc = ``;
46
+ if (options.supermassiveSDL && isSDL(doc)) {
47
+ stringifiedDoc = JSON.stringify(encodeASTSchema(doc));
48
+ } else {
49
+ stringifiedDoc = JSON.stringify(doc);
50
+ if (options.replaceKinds) {
51
+ for (const identifier in Kind) {
52
+ const value = Kind[identifier];
53
+ stringifiedDoc = stringifiedDoc.replace(
54
+ new RegExp(`"kind":"${value}"`, "g"),
55
+ `"kind": Kind.${identifier}`
56
+ );
57
+ }
58
+ }
59
+ }
60
+ const headerCode = [
61
+ options.replaceKinds ? "var Kind = require('graphql/language/kinds');" : "",
62
+ // See https://v8.dev/blog/cost-of-javascript-2019#json
63
+ `var doc = JSON.parse('${stringifiedDoc}');`
64
+ ].join("\n");
65
+ let outputCode = "";
66
+ const operationCount = doc.definitions.reduce((accum, op) => {
67
+ if (op.kind === Kind.OPERATION_DEFINITION) {
68
+ return accum + 1;
69
+ }
70
+ return accum;
71
+ }, 0);
72
+ function exportDefaultStatement(identifier) {
73
+ if (options.esModule) {
74
+ return `export default ${identifier}`;
75
+ }
76
+ return `module.exports = ${identifier}`;
77
+ }
78
+ if (operationCount > 1) {
79
+ throw new Error(
80
+ "GraphQL Webpack Loader allows only for one GraphQL Operation per file"
81
+ );
82
+ }
83
+ outputCode += `${exportDefaultStatement("doc")}`;
84
+ const importOutputCode = expandImports(source, options);
85
+ const allCode = [headerCode, importOutputCode, outputCode, ""].join("\n");
86
+ return allCode;
87
+ }
88
+ export {
89
+ graphqlLoader as default
90
+ };
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/index.ts"],
4
+ "sourcesContent": ["import { DocumentNode, isExecutableDefinitionNode, Kind } from \"graphql\";\nimport type { LoaderContext } from \"webpack\";\nimport {\n optimizeDocumentNode,\n removeDescriptions,\n removeEmptyNodes,\n} from \"@graphql-tools/optimize\";\nimport { uniqueCode } from \"@graphql-tools/webpack-loader-runtime\";\nimport { encodeASTSchema } from \"@graphitation/supermassive\";\nimport { parseDocument } from \"./parser\";\n\nfunction isSDL(doc: DocumentNode) {\n return !doc.definitions.some((def) => isExecutableDefinitionNode(def));\n}\n\ninterface Options {\n noDescription?: boolean;\n noEmptyNodes?: boolean;\n noLoc?: boolean;\n replaceKinds?: boolean;\n esModule?: boolean;\n importHelpers?: boolean;\n supermassiveSDL?: boolean;\n}\n\nfunction expandImports(source: string, options: Options) {\n const lines = source.trim().split(/[\\r\\n]+/);\n const outputHeader = options.importHelpers\n ? `\nvar useUnique = require('@graphql-tools/webpack-loader-runtime').useUnique;\nvar unique = useUnique();`\n : `${uniqueCode}`;\n\n let outputCode = ``;\n lines.some((line) => {\n if (line[0] === \"#\" && line.slice(1).split(\" \")[0] === \"import\") {\n const importFile = line.slice(1).split(\" \")[1];\n const parseDocument = `require(${importFile})`;\n const appendDef = `doc.definitions = doc.definitions.concat(unique(${parseDocument}.definitions));`;\n outputCode += appendDef + \"\\n\";\n }\n return line.length !== 0 && line[0] !== \"#\";\n });\n\n return outputCode.trim().length > 0 ? outputHeader + \"\\n\" + outputCode : ``;\n}\n\nexport default function graphqlLoader(\n this: LoaderContext<Options>,\n source: string,\n) {\n this.cacheable();\n // TODO: This should probably use this.getOptions()\n const options = (this.query as Options) || {};\n let doc = parseDocument(source);\n\n const optimizers = [];\n\n if (options.noDescription) {\n optimizers.push(removeDescriptions);\n }\n if (options.noEmptyNodes) {\n optimizers.push(removeEmptyNodes);\n }\n\n if (optimizers.length > 0 && isSDL(doc)) {\n doc = optimizeDocumentNode(doc, optimizers);\n }\n\n let stringifiedDoc = ``;\n if (options.supermassiveSDL && isSDL(doc)) {\n stringifiedDoc = JSON.stringify(encodeASTSchema(doc));\n } else {\n stringifiedDoc = JSON.stringify(doc);\n if (options.replaceKinds) {\n for (const identifier in Kind) {\n const value = Kind[identifier as keyof typeof Kind];\n stringifiedDoc = stringifiedDoc.replace(\n new RegExp(`\"kind\":\"${value}\"`, \"g\"),\n `\"kind\": Kind.${identifier}`,\n );\n }\n }\n }\n\n const headerCode = [\n options.replaceKinds ? \"var Kind = require('graphql/language/kinds');\" : \"\",\n // See https://v8.dev/blog/cost-of-javascript-2019#json\n `var doc = JSON.parse('${stringifiedDoc}');`,\n ].join(\"\\n\");\n\n let outputCode = \"\";\n\n // Allow multiple query/mutation definitions in a file. This parses out dependencies\n // at compile time, and then uses those at load time to create minimal query documents\n // We cannot do the latter at compile time due to how the #import code works.\n const operationCount = doc.definitions.reduce<number>((accum, op) => {\n if (op.kind === Kind.OPERATION_DEFINITION) {\n return accum + 1;\n }\n\n return accum;\n }, 0);\n\n function exportDefaultStatement(identifier: string) {\n if (options.esModule) {\n return `export default ${identifier}`;\n }\n\n return `module.exports = ${identifier}`;\n }\n\n if (operationCount > 1) {\n throw new Error(\n \"GraphQL Webpack Loader allows only for one GraphQL Operation per file\",\n );\n }\n\n outputCode += `${exportDefaultStatement(\"doc\")}`;\n\n const importOutputCode = expandImports(source, options);\n const allCode = [headerCode, importOutputCode, outputCode, \"\"].join(\"\\n\");\n\n return allCode;\n}\n"],
5
+ "mappings": ";AAAA,SAAuB,4BAA4B,YAAY;AAE/D;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,kBAAkB;AAC3B,SAAS,uBAAuB;AAChC,SAAS,qBAAqB;AAE9B,SAAS,MAAM,KAAmB;AAChC,SAAO,CAAC,IAAI,YAAY,KAAK,CAAC,QAAQ,2BAA2B,GAAG,CAAC;AACvE;AAYA,SAAS,cAAc,QAAgB,SAAkB;AACvD,QAAM,QAAQ,OAAO,KAAK,EAAE,MAAM,SAAS;AAC3C,QAAM,eAAe,QAAQ,gBACzB;AAAA;AAAA,6BAGA,GAAG;AAEP,MAAI,aAAa;AACjB,QAAM,KAAK,CAAC,SAAS;AACnB,QAAI,KAAK,CAAC,MAAM,OAAO,KAAK,MAAM,CAAC,EAAE,MAAM,GAAG,EAAE,CAAC,MAAM,UAAU;AAC/D,YAAM,aAAa,KAAK,MAAM,CAAC,EAAE,MAAM,GAAG,EAAE,CAAC;AAC7C,YAAMA,iBAAgB,WAAW;AACjC,YAAM,YAAY,mDAAmDA;AACrE,oBAAc,YAAY;AAAA,IAC5B;AACA,WAAO,KAAK,WAAW,KAAK,KAAK,CAAC,MAAM;AAAA,EAC1C,CAAC;AAED,SAAO,WAAW,KAAK,EAAE,SAAS,IAAI,eAAe,OAAO,aAAa;AAC3E;AAEe,SAAR,cAEL,QACA;AACA,OAAK,UAAU;AAEf,QAAM,UAAW,KAAK,SAAqB,CAAC;AAC5C,MAAI,MAAM,cAAc,MAAM;AAE9B,QAAM,aAAa,CAAC;AAEpB,MAAI,QAAQ,eAAe;AACzB,eAAW,KAAK,kBAAkB;AAAA,EACpC;AACA,MAAI,QAAQ,cAAc;AACxB,eAAW,KAAK,gBAAgB;AAAA,EAClC;AAEA,MAAI,WAAW,SAAS,KAAK,MAAM,GAAG,GAAG;AACvC,UAAM,qBAAqB,KAAK,UAAU;AAAA,EAC5C;AAEA,MAAI,iBAAiB;AACrB,MAAI,QAAQ,mBAAmB,MAAM,GAAG,GAAG;AACzC,qBAAiB,KAAK,UAAU,gBAAgB,GAAG,CAAC;AAAA,EACtD,OAAO;AACL,qBAAiB,KAAK,UAAU,GAAG;AACnC,QAAI,QAAQ,cAAc;AACxB,iBAAW,cAAc,MAAM;AAC7B,cAAM,QAAQ,KAAK,UAA+B;AAClD,yBAAiB,eAAe;AAAA,UAC9B,IAAI,OAAO,WAAW,UAAU,GAAG;AAAA,UACnC,gBAAgB;AAAA,QAClB;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,QAAM,aAAa;AAAA,IACjB,QAAQ,eAAe,kDAAkD;AAAA;AAAA,IAEzE,yBAAyB;AAAA,EAC3B,EAAE,KAAK,IAAI;AAEX,MAAI,aAAa;AAKjB,QAAM,iBAAiB,IAAI,YAAY,OAAe,CAAC,OAAO,OAAO;AACnE,QAAI,GAAG,SAAS,KAAK,sBAAsB;AACzC,aAAO,QAAQ;AAAA,IACjB;AAEA,WAAO;AAAA,EACT,GAAG,CAAC;AAEJ,WAAS,uBAAuB,YAAoB;AAClD,QAAI,QAAQ,UAAU;AACpB,aAAO,kBAAkB;AAAA,IAC3B;AAEA,WAAO,oBAAoB;AAAA,EAC7B;AAEA,MAAI,iBAAiB,GAAG;AACtB,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAEA,gBAAc,GAAG,uBAAuB,KAAK;AAE7C,QAAM,mBAAmB,cAAc,QAAQ,OAAO;AACtD,QAAM,UAAU,CAAC,YAAY,kBAAkB,YAAY,EAAE,EAAE,KAAK,IAAI;AAExE,SAAO;AACT;",
6
+ "names": ["parseDocument"]
7
+ }
@@ -0,0 +1,3 @@
1
+ import { DocumentNode } from "graphql";
2
+ export declare function parseDocument(doc: string): DocumentNode;
3
+ //# sourceMappingURL=parser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../src/parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,YAAY,EAKb,MAAM,SAAS,CAAC;AAkEjB,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,gBAmBxC"}
package/lib/parser.js ADDED
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var parser_exports = {};
20
+ __export(parser_exports, {
21
+ parseDocument: () => parseDocument
22
+ });
23
+ module.exports = __toCommonJS(parser_exports);
24
+ var import_graphql = require("graphql");
25
+ function normalize(str) {
26
+ return str.replace(/[\s,]+/g, " ").trim();
27
+ }
28
+ const docCache = {};
29
+ const fragmentSourceMap = {};
30
+ function cacheKeyFromFragment(fragment) {
31
+ return normalize((0, import_graphql.print)(fragment));
32
+ }
33
+ function processFragments(ast) {
34
+ const astFragmentMap = {};
35
+ const definitions = [];
36
+ for (let i = 0; i < ast.definitions.length; i++) {
37
+ const fragmentDefinition = ast.definitions[i];
38
+ if (fragmentDefinition.kind === import_graphql.Kind.FRAGMENT_DEFINITION) {
39
+ const fragmentName = fragmentDefinition.name.value;
40
+ const sourceKey = cacheKeyFromFragment(fragmentDefinition);
41
+ if (Object.prototype.hasOwnProperty.call(fragmentSourceMap, fragmentName) && !fragmentSourceMap[fragmentName][sourceKey]) {
42
+ fragmentSourceMap[fragmentName][sourceKey] = true;
43
+ } else if (!Object.prototype.hasOwnProperty.call(fragmentSourceMap, fragmentName)) {
44
+ fragmentSourceMap[fragmentName] = {};
45
+ fragmentSourceMap[fragmentName][sourceKey] = true;
46
+ }
47
+ if (!astFragmentMap[sourceKey]) {
48
+ astFragmentMap[sourceKey] = true;
49
+ definitions.push(fragmentDefinition);
50
+ }
51
+ } else {
52
+ definitions.push(fragmentDefinition);
53
+ }
54
+ }
55
+ ast.definitions = definitions;
56
+ return ast;
57
+ }
58
+ function parseDocument(doc) {
59
+ const cacheKey = normalize(doc);
60
+ if (docCache[cacheKey]) {
61
+ return docCache[cacheKey];
62
+ }
63
+ const parsed = (0, import_graphql.parse)(doc, {
64
+ noLocation: true
65
+ });
66
+ if (!parsed || parsed.kind !== "Document") {
67
+ throw new Error("Not a valid GraphQL document.");
68
+ }
69
+ docCache[cacheKey] = processFragments(parsed);
70
+ return parsed;
71
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/parser.ts"],
4
+ "sourcesContent": ["import {\n DefinitionNode,\n DocumentNode,\n FragmentDefinitionNode,\n Kind,\n parse,\n print,\n} from \"graphql\";\n\n/**\n * Strip insignificant whitespace\n * Note that this could do a lot more, such as reorder fields etc.\n */\nfunction normalize(str: string) {\n return str.replace(/[\\s,]+/g, \" \").trim();\n}\n\n// A map docString -> graphql document\nconst docCache: Record<string, DocumentNode> = {};\n\n// A map fragmentName -> [normalized source]\nconst fragmentSourceMap: {\n [fragmentName: string]: {\n [sourceKey: string]: boolean;\n };\n} = {};\n\nfunction cacheKeyFromFragment(fragment: FragmentDefinitionNode): string {\n return normalize(print(fragment));\n}\n\n/**\n * Take a unstripped parsed document (query/mutation or even fragment), and\n * check all fragment definitions, checking for name->source uniqueness.\n * We also want to make sure only unique fragments exist in the document.\n */\nfunction processFragments(ast: DocumentNode) {\n const astFragmentMap: Record<string, boolean> = {};\n const definitions: DefinitionNode[] = [];\n\n for (let i = 0; i < ast.definitions.length; i++) {\n const fragmentDefinition = ast.definitions[i];\n\n if (fragmentDefinition.kind === Kind.FRAGMENT_DEFINITION) {\n const fragmentName = fragmentDefinition.name.value;\n const sourceKey = cacheKeyFromFragment(fragmentDefinition);\n\n // We know something about this fragment\n if (\n Object.prototype.hasOwnProperty.call(fragmentSourceMap, fragmentName) &&\n !fragmentSourceMap[fragmentName][sourceKey]\n ) {\n fragmentSourceMap[fragmentName][sourceKey] = true;\n } else if (\n !Object.prototype.hasOwnProperty.call(fragmentSourceMap, fragmentName)\n ) {\n fragmentSourceMap[fragmentName] = {};\n fragmentSourceMap[fragmentName][sourceKey] = true;\n }\n\n if (!astFragmentMap[sourceKey]) {\n astFragmentMap[sourceKey] = true;\n definitions.push(fragmentDefinition);\n }\n } else {\n definitions.push(fragmentDefinition);\n }\n }\n\n (ast as any).definitions = definitions;\n return ast;\n}\n\nexport function parseDocument(doc: string) {\n const cacheKey = normalize(doc);\n\n if (docCache[cacheKey]) {\n return docCache[cacheKey];\n }\n\n const parsed = parse(doc, {\n noLocation: true,\n });\n if (!parsed || parsed.kind !== \"Document\") {\n throw new Error(\"Not a valid GraphQL document.\");\n }\n\n // check that all \"new\" fragments inside the documents are consistent with\n // existing fragments of the same name\n docCache[cacheKey] = processFragments(parsed);\n\n return parsed;\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAOO;AAMP,SAAS,UAAU,KAAa;AAC9B,SAAO,IAAI,QAAQ,WAAW,GAAG,EAAE,KAAK;AAC1C;AAGA,MAAM,WAAyC,CAAC;AAGhD,MAAM,oBAIF,CAAC;AAEL,SAAS,qBAAqB,UAA0C;AACtE,SAAO,cAAU,sBAAM,QAAQ,CAAC;AAClC;AAOA,SAAS,iBAAiB,KAAmB;AAC3C,QAAM,iBAA0C,CAAC;AACjD,QAAM,cAAgC,CAAC;AAEvC,WAAS,IAAI,GAAG,IAAI,IAAI,YAAY,QAAQ,KAAK;AAC/C,UAAM,qBAAqB,IAAI,YAAY,CAAC;AAE5C,QAAI,mBAAmB,SAAS,oBAAK,qBAAqB;AACxD,YAAM,eAAe,mBAAmB,KAAK;AAC7C,YAAM,YAAY,qBAAqB,kBAAkB;AAGzD,UACE,OAAO,UAAU,eAAe,KAAK,mBAAmB,YAAY,KACpE,CAAC,kBAAkB,YAAY,EAAE,SAAS,GAC1C;AACA,0BAAkB,YAAY,EAAE,SAAS,IAAI;AAAA,MAC/C,WACE,CAAC,OAAO,UAAU,eAAe,KAAK,mBAAmB,YAAY,GACrE;AACA,0BAAkB,YAAY,IAAI,CAAC;AACnC,0BAAkB,YAAY,EAAE,SAAS,IAAI;AAAA,MAC/C;AAEA,UAAI,CAAC,eAAe,SAAS,GAAG;AAC9B,uBAAe,SAAS,IAAI;AAC5B,oBAAY,KAAK,kBAAkB;AAAA,MACrC;AAAA,IACF,OAAO;AACL,kBAAY,KAAK,kBAAkB;AAAA,IACrC;AAAA,EACF;AAEA,EAAC,IAAY,cAAc;AAC3B,SAAO;AACT;AAEO,SAAS,cAAc,KAAa;AACzC,QAAM,WAAW,UAAU,GAAG;AAE9B,MAAI,SAAS,QAAQ,GAAG;AACtB,WAAO,SAAS,QAAQ;AAAA,EAC1B;AAEA,QAAM,aAAS,sBAAM,KAAK;AAAA,IACxB,YAAY;AAAA,EACd,CAAC;AACD,MAAI,CAAC,UAAU,OAAO,SAAS,YAAY;AACzC,UAAM,IAAI,MAAM,+BAA+B;AAAA,EACjD;AAIA,WAAS,QAAQ,IAAI,iBAAiB,MAAM;AAE5C,SAAO;AACT;",
6
+ "names": []
7
+ }
package/lib/parser.mjs ADDED
@@ -0,0 +1,56 @@
1
+ // src/parser.ts
2
+ import {
3
+ Kind,
4
+ parse,
5
+ print
6
+ } from "graphql";
7
+ function normalize(str) {
8
+ return str.replace(/[\s,]+/g, " ").trim();
9
+ }
10
+ var docCache = {};
11
+ var fragmentSourceMap = {};
12
+ function cacheKeyFromFragment(fragment) {
13
+ return normalize(print(fragment));
14
+ }
15
+ function processFragments(ast) {
16
+ const astFragmentMap = {};
17
+ const definitions = [];
18
+ for (let i = 0; i < ast.definitions.length; i++) {
19
+ const fragmentDefinition = ast.definitions[i];
20
+ if (fragmentDefinition.kind === Kind.FRAGMENT_DEFINITION) {
21
+ const fragmentName = fragmentDefinition.name.value;
22
+ const sourceKey = cacheKeyFromFragment(fragmentDefinition);
23
+ if (Object.prototype.hasOwnProperty.call(fragmentSourceMap, fragmentName) && !fragmentSourceMap[fragmentName][sourceKey]) {
24
+ fragmentSourceMap[fragmentName][sourceKey] = true;
25
+ } else if (!Object.prototype.hasOwnProperty.call(fragmentSourceMap, fragmentName)) {
26
+ fragmentSourceMap[fragmentName] = {};
27
+ fragmentSourceMap[fragmentName][sourceKey] = true;
28
+ }
29
+ if (!astFragmentMap[sourceKey]) {
30
+ astFragmentMap[sourceKey] = true;
31
+ definitions.push(fragmentDefinition);
32
+ }
33
+ } else {
34
+ definitions.push(fragmentDefinition);
35
+ }
36
+ }
37
+ ast.definitions = definitions;
38
+ return ast;
39
+ }
40
+ function parseDocument(doc) {
41
+ const cacheKey = normalize(doc);
42
+ if (docCache[cacheKey]) {
43
+ return docCache[cacheKey];
44
+ }
45
+ const parsed = parse(doc, {
46
+ noLocation: true
47
+ });
48
+ if (!parsed || parsed.kind !== "Document") {
49
+ throw new Error("Not a valid GraphQL document.");
50
+ }
51
+ docCache[cacheKey] = processFragments(parsed);
52
+ return parsed;
53
+ }
54
+ export {
55
+ parseDocument
56
+ };
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/parser.ts"],
4
+ "sourcesContent": ["import {\n DefinitionNode,\n DocumentNode,\n FragmentDefinitionNode,\n Kind,\n parse,\n print,\n} from \"graphql\";\n\n/**\n * Strip insignificant whitespace\n * Note that this could do a lot more, such as reorder fields etc.\n */\nfunction normalize(str: string) {\n return str.replace(/[\\s,]+/g, \" \").trim();\n}\n\n// A map docString -> graphql document\nconst docCache: Record<string, DocumentNode> = {};\n\n// A map fragmentName -> [normalized source]\nconst fragmentSourceMap: {\n [fragmentName: string]: {\n [sourceKey: string]: boolean;\n };\n} = {};\n\nfunction cacheKeyFromFragment(fragment: FragmentDefinitionNode): string {\n return normalize(print(fragment));\n}\n\n/**\n * Take a unstripped parsed document (query/mutation or even fragment), and\n * check all fragment definitions, checking for name->source uniqueness.\n * We also want to make sure only unique fragments exist in the document.\n */\nfunction processFragments(ast: DocumentNode) {\n const astFragmentMap: Record<string, boolean> = {};\n const definitions: DefinitionNode[] = [];\n\n for (let i = 0; i < ast.definitions.length; i++) {\n const fragmentDefinition = ast.definitions[i];\n\n if (fragmentDefinition.kind === Kind.FRAGMENT_DEFINITION) {\n const fragmentName = fragmentDefinition.name.value;\n const sourceKey = cacheKeyFromFragment(fragmentDefinition);\n\n // We know something about this fragment\n if (\n Object.prototype.hasOwnProperty.call(fragmentSourceMap, fragmentName) &&\n !fragmentSourceMap[fragmentName][sourceKey]\n ) {\n fragmentSourceMap[fragmentName][sourceKey] = true;\n } else if (\n !Object.prototype.hasOwnProperty.call(fragmentSourceMap, fragmentName)\n ) {\n fragmentSourceMap[fragmentName] = {};\n fragmentSourceMap[fragmentName][sourceKey] = true;\n }\n\n if (!astFragmentMap[sourceKey]) {\n astFragmentMap[sourceKey] = true;\n definitions.push(fragmentDefinition);\n }\n } else {\n definitions.push(fragmentDefinition);\n }\n }\n\n (ast as any).definitions = definitions;\n return ast;\n}\n\nexport function parseDocument(doc: string) {\n const cacheKey = normalize(doc);\n\n if (docCache[cacheKey]) {\n return docCache[cacheKey];\n }\n\n const parsed = parse(doc, {\n noLocation: true,\n });\n if (!parsed || parsed.kind !== \"Document\") {\n throw new Error(\"Not a valid GraphQL document.\");\n }\n\n // check that all \"new\" fragments inside the documents are consistent with\n // existing fragments of the same name\n docCache[cacheKey] = processFragments(parsed);\n\n return parsed;\n}\n"],
5
+ "mappings": ";AAAA;AAAA,EAIE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAMP,SAAS,UAAU,KAAa;AAC9B,SAAO,IAAI,QAAQ,WAAW,GAAG,EAAE,KAAK;AAC1C;AAGA,IAAM,WAAyC,CAAC;AAGhD,IAAM,oBAIF,CAAC;AAEL,SAAS,qBAAqB,UAA0C;AACtE,SAAO,UAAU,MAAM,QAAQ,CAAC;AAClC;AAOA,SAAS,iBAAiB,KAAmB;AAC3C,QAAM,iBAA0C,CAAC;AACjD,QAAM,cAAgC,CAAC;AAEvC,WAAS,IAAI,GAAG,IAAI,IAAI,YAAY,QAAQ,KAAK;AAC/C,UAAM,qBAAqB,IAAI,YAAY,CAAC;AAE5C,QAAI,mBAAmB,SAAS,KAAK,qBAAqB;AACxD,YAAM,eAAe,mBAAmB,KAAK;AAC7C,YAAM,YAAY,qBAAqB,kBAAkB;AAGzD,UACE,OAAO,UAAU,eAAe,KAAK,mBAAmB,YAAY,KACpE,CAAC,kBAAkB,YAAY,EAAE,SAAS,GAC1C;AACA,0BAAkB,YAAY,EAAE,SAAS,IAAI;AAAA,MAC/C,WACE,CAAC,OAAO,UAAU,eAAe,KAAK,mBAAmB,YAAY,GACrE;AACA,0BAAkB,YAAY,IAAI,CAAC;AACnC,0BAAkB,YAAY,EAAE,SAAS,IAAI;AAAA,MAC/C;AAEA,UAAI,CAAC,eAAe,SAAS,GAAG;AAC9B,uBAAe,SAAS,IAAI;AAC5B,oBAAY,KAAK,kBAAkB;AAAA,MACrC;AAAA,IACF,OAAO;AACL,kBAAY,KAAK,kBAAkB;AAAA,IACrC;AAAA,EACF;AAEA,EAAC,IAAY,cAAc;AAC3B,SAAO;AACT;AAEO,SAAS,cAAc,KAAa;AACzC,QAAM,WAAW,UAAU,GAAG;AAE9B,MAAI,SAAS,QAAQ,GAAG;AACtB,WAAO,SAAS,QAAQ;AAAA,EAC1B;AAEA,QAAM,SAAS,MAAM,KAAK;AAAA,IACxB,YAAY;AAAA,EACd,CAAC;AACD,MAAI,CAAC,UAAU,OAAO,SAAS,YAAY;AACzC,UAAM,IAAI,MAAM,+BAA+B;AAAA,EACjD;AAIA,WAAS,QAAQ,IAAI,iBAAiB,MAAM;AAE5C,SAAO;AACT;",
6
+ "names": []
7
+ }
package/package.json ADDED
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "@graphitation/webpack-loader",
3
+ "license": "MIT",
4
+ "version": "1.0.0",
5
+ "description": "A fork of @graphql-tools/webpack-loader with supermassive SDL encoding format support",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/microsoft/graphitation.git",
9
+ "directory": "packages/webpack-loader"
10
+ },
11
+ "scripts": {
12
+ "build": "monorepo-scripts build",
13
+ "lint": "monorepo-scripts lint",
14
+ "test": "monorepo-scripts test",
15
+ "types": "monorepo-scripts types",
16
+ "just": "monorepo-scripts"
17
+ },
18
+ "peerDependencies": {
19
+ "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0",
20
+ "@graphitation/supermassive": "^3.0.0"
21
+ },
22
+ "dependencies": {
23
+ "@graphql-tools/optimize": "^1.1.1",
24
+ "@graphql-tools/webpack-loader-runtime": "7.0.0",
25
+ "tslib": "^2.4.0"
26
+ },
27
+ "devDependencies": {
28
+ "@types/webpack": "^5.28.0"
29
+ },
30
+ "sideEffects": false,
31
+ "access": "public",
32
+ "exports": {
33
+ ".": {
34
+ "import": "./lib/index.mjs",
35
+ "require": "./lib/index.js",
36
+ "types": "./lib/index.d.ts"
37
+ }
38
+ },
39
+ "publishConfig": {}
40
+ }