@graphitation/webpack-loader 1.0.2 → 1.0.3
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 +11 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -2
- package/lib/index.js.map +2 -2
- package/lib/index.mjs +1 -2
- package/lib/index.mjs.map +2 -2
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,21 @@
|
|
|
1
1
|
# Change Log - @graphitation/webpack-loader
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Thu, 07 Mar 2024 13:08:07 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## 1.0.3
|
|
8
|
+
|
|
9
|
+
Thu, 07 Mar 2024 13:08:07 GMT
|
|
10
|
+
|
|
11
|
+
### Patches
|
|
12
|
+
|
|
13
|
+
- remove JSON.parse from webpack-loader (vladimir.razuvaev@gmail.com)
|
|
14
|
+
- Bump @graphitation/supermassive to v3.5.0
|
|
15
|
+
|
|
7
16
|
## 1.0.2
|
|
8
17
|
|
|
9
|
-
Wed, 28 Feb 2024 17:
|
|
18
|
+
Wed, 28 Feb 2024 17:44:01 GMT
|
|
10
19
|
|
|
11
20
|
### Patches
|
|
12
21
|
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +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,
|
|
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,UA0Ef"}
|
package/lib/index.js
CHANGED
|
@@ -77,8 +77,7 @@ function graphqlLoader(source) {
|
|
|
77
77
|
}
|
|
78
78
|
const headerCode = [
|
|
79
79
|
options.replaceKinds ? "var Kind = require('graphql/language/kinds');" : "",
|
|
80
|
-
|
|
81
|
-
`var doc = JSON.parse('${stringifiedDoc}');`
|
|
80
|
+
`var doc = ${stringifiedDoc};`
|
|
82
81
|
].join("\n");
|
|
83
82
|
let outputCode = "";
|
|
84
83
|
const operationCount = doc.definitions.reduce((accum, op) => {
|
package/lib/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
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
|
|
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
|
|
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 `var doc = ${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;A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 @@ function graphqlLoader(source) {
|
|
|
59
59
|
}
|
|
60
60
|
const headerCode = [
|
|
61
61
|
options.replaceKinds ? "var Kind = require('graphql/language/kinds');" : "",
|
|
62
|
-
|
|
63
|
-
`var doc = JSON.parse('${stringifiedDoc}');`
|
|
62
|
+
`var doc = ${stringifiedDoc};`
|
|
64
63
|
].join("\n");
|
|
65
64
|
let outputCode = "";
|
|
66
65
|
const operationCount = doc.definitions.reduce((accum, op) => {
|
package/lib/index.mjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
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
|
|
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
|
|
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 `var doc = ${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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AAS,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
6
|
"names": ["parseDocument"]
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphitation/webpack-loader",
|
|
3
3
|
"license": "MIT",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.3",
|
|
5
5
|
"description": "A fork of @graphql-tools/webpack-loader with supermassive SDL encoding format support",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
},
|
|
18
18
|
"peerDependencies": {
|
|
19
19
|
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0",
|
|
20
|
-
"@graphitation/supermassive": "^3.
|
|
20
|
+
"@graphitation/supermassive": "^3.5.0"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@graphql-tools/optimize": "^1.1.1",
|