@shellicar/build-graphql 0.1.1 → 1.0.1
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 +24 -17
- package/dist/astro.cjs +1 -1
- package/dist/astro.js +1 -1
- package/dist/chunk-7BERUFQQ.js +1 -0
- package/dist/chunk-7BERUFQQ.js.map +1 -0
- package/dist/chunk-M2KOJHTB.cjs +1 -0
- package/dist/chunk-M2KOJHTB.cjs.map +1 -0
- package/dist/chunk-MROI2TT6.js +1 -0
- package/dist/chunk-MROI2TT6.js.map +1 -0
- package/dist/chunk-OSLESBPI.js +1 -0
- package/dist/chunk-OSLESBPI.js.map +1 -0
- package/dist/chunk-PHIKG3MI.cjs +1 -0
- package/dist/chunk-PHIKG3MI.cjs.map +1 -0
- package/dist/chunk-UQ7VVNQE.cjs +1 -0
- package/dist/chunk-UQ7VVNQE.cjs.map +1 -0
- package/dist/chunk-WQ3PTPJG.cjs +1 -0
- package/dist/chunk-WQ3PTPJG.cjs.map +1 -0
- package/dist/chunk-YUBBVNLZ.js +1 -0
- package/dist/chunk-YUBBVNLZ.js.map +1 -0
- package/dist/core/defaults.cjs +1 -1
- package/dist/core/defaults.d.cts +0 -1
- package/dist/core/defaults.d.ts +0 -1
- package/dist/core/defaults.js +1 -1
- package/dist/core/graphql.cjs +1 -0
- package/dist/core/graphql.cjs.map +1 -0
- package/dist/core/graphql.d.cts +24 -0
- package/dist/core/graphql.d.ts +24 -0
- package/dist/core/graphql.js +1 -0
- package/dist/core/graphql.js.map +1 -0
- package/dist/core/index.cjs +1 -1
- package/dist/core/index.js +1 -1
- package/dist/core/module.cjs +1 -0
- package/dist/core/module.cjs.map +1 -0
- package/dist/core/module.d.cts +3 -0
- package/dist/core/module.d.ts +3 -0
- package/dist/core/module.js +1 -0
- package/dist/core/module.js.map +1 -0
- package/dist/core/types.d.cts +5 -10
- package/dist/core/types.d.ts +5 -10
- package/dist/esbuild.cjs +1 -1
- package/dist/esbuild.js +1 -1
- package/dist/farm.cjs +1 -1
- package/dist/farm.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/nuxt.cjs +1 -1
- package/dist/nuxt.cjs.map +1 -1
- package/dist/nuxt.js +1 -1
- package/dist/nuxt.js.map +1 -1
- package/dist/rollup.cjs +1 -1
- package/dist/rollup.js +1 -1
- package/dist/rspack.cjs +1 -1
- package/dist/rspack.js +1 -1
- package/dist/vite.cjs +1 -1
- package/dist/vite.js +1 -1
- package/dist/webpack.cjs +1 -1
- package/dist/webpack.js +1 -1
- package/package.json +150 -45
- package/CHANGELOG.md +0 -14
- package/dist/chunk-OLAXA3NW.cjs +0 -1
- package/dist/chunk-OLAXA3NW.cjs.map +0 -1
- package/dist/chunk-Q6776UY5.js +0 -1
- package/dist/chunk-Q6776UY5.js.map +0 -1
- package/dist/chunk-QBNFT4HT.js +0 -1
- package/dist/chunk-QBNFT4HT.js.map +0 -1
- package/dist/chunk-VLAENKR2.cjs +0 -1
- package/dist/chunk-VLAENKR2.cjs.map +0 -1
package/README.md
CHANGED
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
# @shellicar/build-graphql
|
|
2
2
|
|
|
3
|
-
Build plugin that loads GraphQL files and makes them available through a virtual module import.
|
|
3
|
+
> Build plugin that loads GraphQL files and makes them available through a virtual module import.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
## Usage
|
|
5
|
+
## Installation & Quick Start
|
|
8
6
|
|
|
9
7
|
```sh
|
|
10
|
-
|
|
8
|
+
npm i --save @shellicar/build-graphql
|
|
11
9
|
```
|
|
12
10
|
|
|
13
|
-
|
|
11
|
+
```sh
|
|
12
|
+
pnpm add @shellicar/build-graphql
|
|
13
|
+
```
|
|
14
14
|
|
|
15
15
|
```ts
|
|
16
|
+
// build.ts
|
|
16
17
|
import GraphQLPlugin from '@shellicar/build-graphql/esbuild'
|
|
17
18
|
|
|
18
|
-
build({
|
|
19
|
+
await build({
|
|
19
20
|
// other options
|
|
20
21
|
plugins: [
|
|
21
22
|
GraphQLPlugin({
|
|
@@ -25,19 +26,25 @@ build({
|
|
|
25
26
|
})
|
|
26
27
|
```
|
|
27
28
|
|
|
28
|
-
|
|
29
|
+
```ts
|
|
30
|
+
// vite.config.ts
|
|
31
|
+
import GraphQLPlugin from '@shellicar/build-graphql/vite'
|
|
32
|
+
|
|
33
|
+
export default defineConfig({
|
|
34
|
+
// other options
|
|
35
|
+
plugins: [
|
|
36
|
+
GraphQLPlugin({
|
|
37
|
+
globPattern: 'src/**/*.graphql'
|
|
38
|
+
})
|
|
39
|
+
],
|
|
40
|
+
});
|
|
41
|
+
```
|
|
29
42
|
|
|
30
43
|
```ts
|
|
44
|
+
// main.ts
|
|
31
45
|
import typedefs from '@shellicar/build-graphql/typedefs'
|
|
32
46
|
```
|
|
33
47
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
## Options
|
|
37
|
-
|
|
38
|
-
See [types.ts](./packages/build-graphql/src/core/types.ts) for detailed options documentation.
|
|
39
|
-
|
|
40
|
-
## Credits
|
|
48
|
+
## Documentation
|
|
41
49
|
|
|
42
|
-
|
|
43
|
-
- [unplugin](https://github.com/unjs/unplugin)
|
|
50
|
+
For full documentation, visit [here](https://github.com/shellicar/build-graphql).
|
package/dist/astro.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("./chunk-
|
|
1
|
+
"use strict";var e=require("./chunk-WQ3PTPJG.cjs");require("./chunk-UQ7VVNQE.cjs"),require("./chunk-PHIKG3MI.cjs"),require("./chunk-M2KOJHTB.cjs");var u=require("./chunk-PK6SKIKE.cjs"),r=u.__name((r=>({name:"build-graphql",hooks:{"astro:config:setup":u.__name((async u=>{u.config.vite.plugins||=[],u.config.vite.plugins.push(e.plugin.vite(r))}),"astro:config:setup")}})),"default");module.exports=r,module.exports=exports.default;//# sourceMappingURL=astro.cjs.map
|
package/dist/astro.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{plugin as o}from"./chunk-
|
|
1
|
+
import{plugin as o}from"./chunk-YUBBVNLZ.js";import"./chunk-7BERUFQQ.js";import"./chunk-MROI2TT6.js";import"./chunk-OSLESBPI.js";import{__name as i}from"./chunk-7QVYU63E.js";var s=i((s=>({name:"build-graphql",hooks:{"astro:config:setup":i((async i=>{i.config.vite.plugins||=[],i.config.vite.plugins.push(o.vite(s))}),"astro:config:setup")}})),"default");export{s as default};//# sourceMappingURL=astro.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var r={globPattern:"**/*.graphql",globIgnore:"**/node_modules/**",ignoreErrors:!1,debug:!1};export{r as defaults};//# sourceMappingURL=chunk-7BERUFQQ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/defaults.ts"],"names":[],"mappings":";AAEO,IAAM,QAAW,GAAA;AAAA,EACtB,WAAa,EAAA,cAAA;AAAA,EACb,UAAY,EAAA,oBAAA;AAAA,EACZ,YAAc,EAAA,KAAA;AAAA,EACd,KAAO,EAAA;AACT","file":"chunk-7BERUFQQ.js","sourcesContent":["import type { Options } from './types';\n\nexport const defaults = {\n globPattern: '**/*.graphql',\n globIgnore: '**/node_modules/**',\n ignoreErrors: false,\n debug: false,\n} as const satisfies Options;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";exports.virtualModuleId="@shellicar/build-graphql/typedefs";//# sourceMappingURL=chunk-M2KOJHTB.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../package.json","../src/core/module.ts"],"names":[],"mappings":";AACE,IAAQ,IAAA,GAAA,0BAAA;;;ACCV,IAAM,eAAkB,GAAA,UAAA;AAEjB,IAAM,eAAkB,GAAA,CAAA,EAAG,IAAI,CAAA,CAAA,EAAI,eAAe,CAAA","file":"chunk-M2KOJHTB.cjs","sourcesContent":["{\n \"name\": \"@shellicar/build-graphql\",\n \"private\": false,\n \"version\": \"1.0.1\",\n \"type\": \"module\",\n \"license\": \"MIT\",\n \"author\": \"Stephen Hellicar\",\n \"description\": \"Build plugin that loads GraphQL files and makes them importable via a virtual typedefs module.\",\n \"keywords\": [\"build\", \"plugin\", \"graphql\", \"esbuild\", \"vite\"],\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/shellicar/build-graphql.git\"\n },\n \"bugs\": {\n \"url\": \"https://github.com/shellicar/build-graphql/issues\"\n },\n \"homepage\": \"https://github.com/shellicar/build-graphql#readme\",\n \"publishConfig\": {\n \"access\": \"public\"\n },\n \"exports\": {\n \".\": {\n \"require\": {\n \"types\": \"./dist/index.d.cts\",\n \"default\": \"./dist/index.cjs\"\n },\n \"import\": {\n \"types\": \"./dist/index.d.ts\",\n \"default\": \"./dist/index.js\"\n }\n },\n \"./astro\": {\n \"require\": {\n \"types\": \"./dist/astro.d.cts\",\n \"default\": \"./dist/astro.cjs\"\n },\n \"import\": {\n \"types\": \"./dist/astro.d.ts\",\n \"default\": \"./dist/astro.js\"\n }\n },\n \"./rspack\": {\n \"require\": {\n \"types\": \"./dist/rspack.d.cts\",\n \"default\": \"./dist/rspack.cjs\"\n },\n \"import\": {\n \"types\": \"./dist/rspack.d.ts\",\n \"default\": \"./dist/rspack.js\"\n }\n },\n \"./vite\": {\n \"require\": {\n \"types\": \"./dist/vite.d.cts\",\n \"default\": \"./dist/vite.cjs\"\n },\n \"import\": {\n \"types\": \"./dist/vite.d.ts\",\n \"default\": \"./dist/vite.js\"\n }\n },\n \"./webpack\": {\n \"require\": {\n \"types\": \"./dist/webpack.d.cts\",\n \"default\": \"./dist/webpack.cjs\"\n },\n \"import\": {\n \"types\": \"./dist/webpack.d.ts\",\n \"default\": \"./dist/webpack.js\"\n }\n },\n \"./rollup\": {\n \"require\": {\n \"types\": \"./dist/rollup.d.cts\",\n \"default\": \"./dist/rollup.cjs\"\n },\n \"import\": {\n \"types\": \"./dist/rollup.d.ts\",\n \"default\": \"./dist/rollup.js\"\n }\n },\n \"./esbuild\": {\n \"require\": {\n \"types\": \"./dist/esbuild.d.cts\",\n \"default\": \"./dist/esbuild.cjs\"\n },\n \"import\": {\n \"types\": \"./dist/esbuild.d.ts\",\n \"default\": \"./dist/esbuild.js\"\n }\n },\n \"./nuxt\": {\n \"require\": {\n \"types\": \"./dist/nuxt.d.cts\",\n \"default\": \"./dist/nuxt.cjs\"\n },\n \"import\": {\n \"types\": \"./dist/nuxt.d.ts\",\n \"default\": \"./dist/nuxt.js\"\n }\n },\n \"./farm\": {\n \"require\": {\n \"types\": \"./dist/farm.d.cts\",\n \"default\": \"./dist/farm.cjs\"\n },\n \"import\": {\n \"types\": \"./dist/farm.d.ts\",\n \"default\": \"./dist/farm.js\"\n }\n },\n \"./types\": {\n \"require\": {\n \"types\": \"./dist/core/types.d.cts\",\n \"default\": \"./dist/core/types.cjs\"\n },\n \"import\": {\n \"types\": \"./dist/core/types.d.ts\",\n \"default\": \"./dist/core/types.js\"\n }\n },\n \"./typedefs\": {\n \"require\": {\n \"types\": \"./dist/core/typedefs.d.cts\",\n \"default\": \"./dist/core/typedefs.cjs\"\n },\n \"import\": {\n \"types\": \"./dist/core/typedefs.d.ts\",\n \"default\": \"./dist/core/typedefs.js\"\n }\n },\n \"./*\": {\n \"require\": {\n \"types\": \"./dist/*.d.cts\",\n \"default\": \"./dist/*.cjs\"\n },\n \"import\": {\n \"types\": \"./dist/*.d.ts\",\n \"default\": \"./dist/*.js\"\n }\n }\n },\n \"main\": \"dist/index.cjs\",\n \"module\": \"dist/index.js\",\n \"types\": \"dist/index.d.ts\",\n \"typesVersions\": {\n \"*\": {\n \"astro\": [\"./dist/astro.d.ts\"],\n \"rspack\": [\"./dist/rspack.d.ts\"],\n \"vite\": [\"./dist/vite.d.ts\"],\n \"webpack\": [\"./dist/webpack.d.ts\"],\n \"rollup\": [\"./dist/rollup.d.ts\"],\n \"esbuild\": [\"./dist/esbuild.d.ts\"],\n \"nuxt\": [\"./dist/nuxt.d.ts\"],\n \"farm\": [\"./dist/farm.d.ts\"],\n \"types\": [\"./dist/core/types.d.ts\"],\n \"typedefs\": [\"./dist/core/typedefs.d.ts\"],\n \"*\": [\"./dist/*\"]\n }\n },\n \"files\": [\"dist\", \"*.md\"],\n \"scripts\": {\n \"build\": \"tsup\",\n \"dev\": \"tsup --watch\",\n \"type-check\": \"tsc -p tsconfig.check.json\"\n },\n \"peerDependencies\": {\n \"@farmfe/core\": \">=1\",\n \"@nuxt/kit\": \"^3\",\n \"@nuxt/schema\": \"^3\",\n \"esbuild\": \"*\",\n \"rollup\": \"^3\",\n \"vite\": \"^6\",\n \"webpack\": \"^4 || ^5\"\n },\n \"peerDependenciesMeta\": {\n \"@farmfe/core\": {\n \"optional\": true\n },\n \"@nuxt/kit\": {\n \"optional\": true\n },\n \"@nuxt/schema\": {\n \"optional\": true\n },\n \"esbuild\": {\n \"optional\": true\n },\n \"rollup\": {\n \"optional\": true\n },\n \"vite\": {\n \"optional\": true\n },\n \"webpack\": {\n \"optional\": true\n }\n },\n \"devDependencies\": {\n \"@luckycatfactory/esbuild-graphql-loader\": \"^3.8.1\",\n \"@nuxt/kit\": \"^3.15.1\",\n \"@nuxt/schema\": \"^3.15.1\",\n \"@tsconfig/node20\": \"^20.1.4\",\n \"@types/node\": \"^22.10.5\",\n \"bumpp\": \"^9.9.2\",\n \"chalk\": \"^5.4.1\",\n \"esno\": \"^4.8.0\",\n \"npm-check-updates\": \"^17.1.13\",\n \"npm-run-all2\": \"^7.0.2\",\n \"rollup\": \"^4.30.0\",\n \"terser\": \"^5.37.0\",\n \"tsup\": \"^8.3.5\",\n \"vite\": \"^6.0.7\",\n \"vitest\": \"^2.1.8\",\n \"webpack\": \"^5.97.1\"\n },\n \"dependencies\": {\n \"glob\": \"^11.0.0\",\n \"graphql\": \"^16.10.0\",\n \"graphql-tag\": \"^2.12.6\",\n \"unplugin\": \"^2.1.2\"\n }\n}\n","import { name } from '../../package.json';\n\nconst exportSpecifier = 'typedefs';\n\nexport const virtualModuleId = `${name}/${exportSpecifier}`;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{__name as e}from"./chunk-7QVYU63E.js";import t from"node:path";import n from"fs";import o from"graphql-tag";import r from"readline";import a from"path";import{glob as i}from"glob";var s=e(((e,t)=>{const n=t?t(e):e;return JSON.stringify(n,((e,t)=>void 0===t?"__undefined":t)).replace(/"__undefined"/g,"undefined")}),"generateDocumentNodeString"),l=e(((t,n)=>{const o=new Set,r=[],a=e((e=>{o.has(e)||(o.add(e),e.imports.forEach((e=>{const t=n[e.absolutePath];a(t)})),r.unshift(e))}),"visitFile");return t.forEach(a),r}),"topologicallySortParsedFiles"),c=e((t=>new Promise((o=>{const i=r.createInterface({input:n.createReadStream(t)});let s="";const l=[];let c=!1;const m=e(((e,n)=>{const o=n.replace(e,""),r=o.replace(/"|'/g,""),i=a.join(a.dirname(t),r);l.push({absolutePath:i,relativePath:o})}),"parseImportAndCapture");i.on("line",(e=>{e.startsWith("#import ")?m("#import ",e):e.startsWith("# import ")?m("# import ",e):c?s+=e+"\n":"#"!==e[0]&&""!==e&&(c=!0,s+=e+"\n")})),i.on("close",(()=>{o({body:s.trim(),filePath:t,imports:l})}))}))),"parseGraphQLFile"),m=e((t=>{const n={},o=[],r=new Set,a=e((e=>n[e]?Promise.resolve(null):new Promise((t=>{c(e).then((e=>{n[e.filePath]=e,e.imports.forEach((e=>{r.has(e.absolutePath)||(r.add(e.absolutePath),o.push(a(e.absolutePath)))}));const i=o.shift();return i?i.then(t):t(null)}))}))),"visitAndParse");return a(t).then((()=>l(Object.values(n),n).reduce(((e,t)=>t.body+"\n\n"+e),"")))}),"generateGraphQLString"),p=e(((e,t,n)=>{const o={kind:"Document",definitions:[e,...t]};return s(o,n)}),"generateDocumentNodeStringForOperationDefinition"),d=e((t=>e(((e,t)=>(e.forEach((e=>{"FragmentDefinition"===e.kind&&(t[e.name.value]=e)})),t)),"accumulateAllFragments")(t.definitions,{})),"collectAllFragmentDefinitions"),u=e(((t,n)=>{const o=[],r=e((e=>{if("FragmentSpread"===e.kind){const t=n[e.name.value],r=u(t,n);o.push(...r,e.name.value)}}),"handleSelectionNode");return"OperationDefinition"===t.kind?t.selectionSet.selections.forEach((e=>{var t;"Field"===e.kind&&(null==(t=e.selectionSet)||t.selections.forEach(r))})):t.selectionSet.selections.forEach(r),o}),"collectAllFragmentReferences"),f=e(((e,t)=>{const n=o(e),r=s(n,t),a=d(n),i=n.definitions.reduce(((e,n)=>{if("OperationDefinition"===n.kind&&n.name&&n.name.value){const o=n.name.value,r=u(n,a).map((e=>{const t=a[e];if(!t)throw new Error(`Expected to find fragment definition for ${e}`);return t})),i=p(n,r,t);e.push(`export const ${o} = ${i};`)}return e}),[`const documentNode = ${r};`]);return i.push("export default documentNode;"),i.join("\n")}),"generateContentsFromGraphqlString"),h=e((async e=>(await i(e.globPattern,{ignore:e.globIgnore})).map(((e,n)=>({path:t.join(process.cwd(),e).replace(/\\/g,"/"),name:`gql_${n}`})))),"findGraphQLFiles"),g=e((e=>[...e.map((e=>`import ${e.name} from '${e.path}';`)),`export default ${`[${e.map((e=>e.name)).join(", ")}]`};`].join("\n")),"generateTypedefsFile"),P=e((async(e,t)=>{const n=await h(e),o=g(n);return t.debug(`Typedefs: \`${o}\``),{code:o,map:null}}),"loadVirtualModule"),S=e((async(e,t,n)=>{if(e.startsWith("\0")&&e.endsWith(".graphql")){const n=e.slice(1),o=await m(n);return{code:f(o,t.mapDocumentNode),map:null}}}),"loadGraphqlModule");export{h as findGraphQLFiles,S as loadGraphqlModule,P as loadVirtualModule};//# sourceMappingURL=chunk-MROI2TT6.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../node_modules/.pnpm/@luckycatfactory+esbuild-graphql-loader@3.8.1_esbuild@0.24.2_graphql-tag@2.12.6_graphql@16.10.0__graphql@16.10.0/node_modules/@luckycatfactory/esbuild-graphql-loader/lib/index.mjs","../src/core/graphql.ts"],"names":[],"mappings":"sMAKA,IAAI,0BAAA,m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AsB,MAAM,CAAA;AACxD,IAAA,MAAM,IAAO,GAAA,iCAAA,CAAkC,aAAe,EAAA,OAAA,CAAQ,eAAe,CAAA;AACrF,IAAO,OAAA;AAAA,MACL,IAAA;AAAA,MACA,GAAK,EAAA;AAAA,KACP;AAAA;AAEF,EAAO,OAAA,SAAA;AACT,CAXiC,EAAA,mBAAA","file":"chunk-MROI2TT6.js","sourcesContent":["// src/index.ts\nimport fs2 from \"fs\";\nimport gql from \"graphql-tag\";\nimport readline2 from \"readline\";\nimport path2 from \"path\";\nvar generateDocumentNodeString = (graphqlDocument, mapDocumentNode) => {\n const documentNodeToUse = mapDocumentNode ? mapDocumentNode(graphqlDocument) : graphqlDocument;\n return JSON.stringify(documentNodeToUse, (key, value) => value === void 0 ? \"__undefined\" : value).replace(/\"__undefined\"/g, \"undefined\");\n};\nvar topologicallySortParsedFiles = (parsedFiles, cache) => {\n const visitedFiles = new Set();\n const sorted = [];\n const visitFile = (file) => {\n if (visitedFiles.has(file))\n return;\n visitedFiles.add(file);\n file.imports.forEach((importFileEntry) => {\n const importedFile = cache[importFileEntry.absolutePath];\n visitFile(importedFile);\n });\n sorted.unshift(file);\n };\n parsedFiles.forEach(visitFile);\n return sorted;\n};\nvar parseGraphQLFile = (filePath) => new Promise((resolve) => {\n const readInterface = readline2.createInterface({\n input: fs2.createReadStream(filePath)\n });\n let body = \"\";\n const imports = [];\n let hasExhaustedImports = false;\n const parseImportAndCapture = (importCommentPrefix, line) => {\n const relativePath = line.replace(importCommentPrefix, \"\");\n const relativePathWithoutQuotations = relativePath.replace(/\"|'/g, \"\");\n const absolutePath = path2.join(path2.dirname(filePath), relativePathWithoutQuotations);\n imports.push({\n absolutePath,\n relativePath\n });\n };\n readInterface.on(\"line\", (line) => {\n if (line.startsWith(\"#import \")) {\n parseImportAndCapture(\"#import \", line);\n } else if (line.startsWith(\"# import \")) {\n parseImportAndCapture(\"# import \", line);\n } else if (hasExhaustedImports) {\n body += line + \"\\n\";\n } else if (line[0] !== \"#\" && line !== \"\") {\n hasExhaustedImports = true;\n body += line + \"\\n\";\n }\n });\n readInterface.on(\"close\", () => {\n resolve({body: body.trim(), filePath, imports});\n });\n});\nvar generateGraphQLString = (entryPointPath) => {\n const cache = {};\n const parsePromises = [];\n const seenImportPaths = new Set();\n const visitAndParse = (filePath) => {\n if (cache[filePath])\n return Promise.resolve(null);\n return new Promise((resolve) => {\n parseGraphQLFile(filePath).then((parsedFile) => {\n cache[parsedFile.filePath] = parsedFile;\n parsedFile.imports.forEach((importEntry) => {\n if (!seenImportPaths.has(importEntry.absolutePath)) {\n seenImportPaths.add(importEntry.absolutePath);\n parsePromises.push(visitAndParse(importEntry.absolutePath));\n }\n });\n const nextPromise = parsePromises.shift();\n if (nextPromise) {\n return nextPromise.then(resolve);\n }\n return resolve(null);\n });\n });\n };\n return visitAndParse(entryPointPath).then(() => {\n const files = topologicallySortParsedFiles(Object.values(cache), cache);\n const graphqlString = files.reduce((accumulator, file) => {\n return file.body + \"\\n\\n\" + accumulator;\n }, \"\");\n return graphqlString;\n });\n};\nvar generateDocumentNodeStringForOperationDefinition = (operationDefinition, fragments, mapDocumentNode) => {\n const operationDocument = {\n kind: \"Document\",\n definitions: [operationDefinition, ...fragments]\n };\n return generateDocumentNodeString(operationDocument, mapDocumentNode);\n};\nvar collectAllFragmentDefinitions = (documentNode) => {\n const accumulateAllFragments = (nodes, accumulator) => {\n nodes.forEach((node) => {\n if (node.kind === \"FragmentDefinition\") {\n accumulator[node.name.value] = node;\n }\n });\n return accumulator;\n };\n return accumulateAllFragments(documentNode.definitions, {});\n};\nvar collectAllFragmentReferences = (node, allFragments) => {\n const references = [];\n const handleSelectionNode = (selection) => {\n if (selection.kind === \"FragmentSpread\") {\n const fragment = allFragments[selection.name.value];\n const innerFragmentReferences = collectAllFragmentReferences(fragment, allFragments);\n references.push(...innerFragmentReferences, selection.name.value);\n }\n };\n if (node.kind === \"OperationDefinition\") {\n node.selectionSet.selections.forEach((selection) => {\n var _a;\n if (selection.kind === \"Field\") {\n (_a = selection.selectionSet) == null ? void 0 : _a.selections.forEach(handleSelectionNode);\n }\n });\n } else {\n node.selectionSet.selections.forEach(handleSelectionNode);\n }\n return references;\n};\nvar generateContentsFromGraphqlString = (graphqlString, mapDocumentNode) => {\n const graphqlDocument = gql(graphqlString);\n const documentNodeAsString = generateDocumentNodeString(graphqlDocument, mapDocumentNode);\n const allFragments = collectAllFragmentDefinitions(graphqlDocument);\n const lines = graphqlDocument.definitions.reduce((accumulator, definition) => {\n if (definition.kind === \"OperationDefinition\" && definition.name && definition.name.value) {\n const name = definition.name.value;\n const fragmentsForOperation = collectAllFragmentReferences(definition, allFragments);\n const fragments = fragmentsForOperation.map((fragmentForOperation) => {\n const fragment = allFragments[fragmentForOperation];\n if (!fragment) {\n throw new Error(`Expected to find fragment definition for ${fragmentForOperation}`);\n }\n return fragment;\n });\n const operationDocumentString = generateDocumentNodeStringForOperationDefinition(definition, fragments, mapDocumentNode);\n accumulator.push(`export const ${name} = ${operationDocumentString};`);\n }\n return accumulator;\n }, [`const documentNode = ${documentNodeAsString};`]);\n lines.push(`export default documentNode;`);\n return lines.join(\"\\n\");\n};\nvar graphqlLoaderPlugin = (options = {}) => ({\n name: \"graphql-loader\",\n setup(build) {\n build.onLoad({filter: options.filterRegex || /\\.graphql$|\\.gql$/}, (args) => generateGraphQLString(args.path).then((graphqlString) => ({\n contents: generateContentsFromGraphqlString(graphqlString, options.mapDocumentNode)\n })));\n }\n});\nvar src_default = graphqlLoaderPlugin;\nexport {\n src_default as default,\n generateContentsFromGraphqlString,\n generateGraphQLString\n};\n","import path from 'node:path';\nimport { generateContentsFromGraphqlString, generateGraphQLString } from '@luckycatfactory/esbuild-graphql-loader';\nimport { glob } from 'glob';\nimport type { DocumentNode } from 'graphql';\nimport type { ILogger } from './types';\n\ntype GraphqlFile = {\n path: string;\n name: string;\n};\n\nexport const findGraphQLFiles = async (options: { globPattern: string; globIgnore: string }): Promise<GraphqlFile[]> => {\n const files = await glob(options.globPattern, { ignore: options.globIgnore });\n return files.map((file, index) => ({\n path: path.join(process.cwd(), file).replace(/\\\\/g, '/'),\n name: `gql_${index}`,\n }));\n};\n\nconst generateTypedefsFile = (files: GraphqlFile[]) => {\n const importStatements = files.map((f) => `import ${f.name} from '${f.path}';`);\n\n const documentsArray = `[${files.map((f) => f.name).join(', ')}]`;\n\n const code = [...importStatements, `export default ${documentsArray};`];\n return code.join('\\n');\n};\n\ntype TransformResult =\n | {\n code: string;\n map: null;\n }\n | null\n | undefined;\n\nexport const loadVirtualModule = async (options: { globPattern: string; globIgnore: string }, logger: ILogger): Promise<TransformResult> => {\n const files = await findGraphQLFiles(options);\n const code = generateTypedefsFile(files);\n logger.debug(`Typedefs: \\`${code}\\``);\n return { code, map: null };\n};\n\nexport const loadGraphqlModule = async (id: string, options: { mapDocumentNode?: (documentNode: DocumentNode) => DocumentNode }, logger: ILogger): Promise<TransformResult> => {\n if (id.startsWith('\\0') && id.endsWith('.graphql')) {\n const realId = id.slice(1);\n const graphqlString = await generateGraphQLString(realId);\n const code = generateContentsFromGraphqlString(graphqlString, options.mapDocumentNode);\n return {\n code,\n map: null,\n };\n }\n return undefined;\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e="@shellicar/build-graphql/typedefs";export{e as virtualModuleId};//# sourceMappingURL=chunk-OSLESBPI.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../package.json","../src/core/module.ts"],"names":[],"mappings":";AACE,IAAQ,IAAA,GAAA,0BAAA;;;ACCV,IAAM,eAAkB,GAAA,UAAA;AAEjB,IAAM,eAAkB,GAAA,CAAA,EAAG,IAAI,CAAA,CAAA,EAAI,eAAe,CAAA","file":"chunk-OSLESBPI.js","sourcesContent":["{\n \"name\": \"@shellicar/build-graphql\",\n \"private\": false,\n \"version\": \"1.0.1\",\n \"type\": \"module\",\n \"license\": \"MIT\",\n \"author\": \"Stephen Hellicar\",\n \"description\": \"Build plugin that loads GraphQL files and makes them importable via a virtual typedefs module.\",\n \"keywords\": [\"build\", \"plugin\", \"graphql\", \"esbuild\", \"vite\"],\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/shellicar/build-graphql.git\"\n },\n \"bugs\": {\n \"url\": \"https://github.com/shellicar/build-graphql/issues\"\n },\n \"homepage\": \"https://github.com/shellicar/build-graphql#readme\",\n \"publishConfig\": {\n \"access\": \"public\"\n },\n \"exports\": {\n \".\": {\n \"require\": {\n \"types\": \"./dist/index.d.cts\",\n \"default\": \"./dist/index.cjs\"\n },\n \"import\": {\n \"types\": \"./dist/index.d.ts\",\n \"default\": \"./dist/index.js\"\n }\n },\n \"./astro\": {\n \"require\": {\n \"types\": \"./dist/astro.d.cts\",\n \"default\": \"./dist/astro.cjs\"\n },\n \"import\": {\n \"types\": \"./dist/astro.d.ts\",\n \"default\": \"./dist/astro.js\"\n }\n },\n \"./rspack\": {\n \"require\": {\n \"types\": \"./dist/rspack.d.cts\",\n \"default\": \"./dist/rspack.cjs\"\n },\n \"import\": {\n \"types\": \"./dist/rspack.d.ts\",\n \"default\": \"./dist/rspack.js\"\n }\n },\n \"./vite\": {\n \"require\": {\n \"types\": \"./dist/vite.d.cts\",\n \"default\": \"./dist/vite.cjs\"\n },\n \"import\": {\n \"types\": \"./dist/vite.d.ts\",\n \"default\": \"./dist/vite.js\"\n }\n },\n \"./webpack\": {\n \"require\": {\n \"types\": \"./dist/webpack.d.cts\",\n \"default\": \"./dist/webpack.cjs\"\n },\n \"import\": {\n \"types\": \"./dist/webpack.d.ts\",\n \"default\": \"./dist/webpack.js\"\n }\n },\n \"./rollup\": {\n \"require\": {\n \"types\": \"./dist/rollup.d.cts\",\n \"default\": \"./dist/rollup.cjs\"\n },\n \"import\": {\n \"types\": \"./dist/rollup.d.ts\",\n \"default\": \"./dist/rollup.js\"\n }\n },\n \"./esbuild\": {\n \"require\": {\n \"types\": \"./dist/esbuild.d.cts\",\n \"default\": \"./dist/esbuild.cjs\"\n },\n \"import\": {\n \"types\": \"./dist/esbuild.d.ts\",\n \"default\": \"./dist/esbuild.js\"\n }\n },\n \"./nuxt\": {\n \"require\": {\n \"types\": \"./dist/nuxt.d.cts\",\n \"default\": \"./dist/nuxt.cjs\"\n },\n \"import\": {\n \"types\": \"./dist/nuxt.d.ts\",\n \"default\": \"./dist/nuxt.js\"\n }\n },\n \"./farm\": {\n \"require\": {\n \"types\": \"./dist/farm.d.cts\",\n \"default\": \"./dist/farm.cjs\"\n },\n \"import\": {\n \"types\": \"./dist/farm.d.ts\",\n \"default\": \"./dist/farm.js\"\n }\n },\n \"./types\": {\n \"require\": {\n \"types\": \"./dist/core/types.d.cts\",\n \"default\": \"./dist/core/types.cjs\"\n },\n \"import\": {\n \"types\": \"./dist/core/types.d.ts\",\n \"default\": \"./dist/core/types.js\"\n }\n },\n \"./typedefs\": {\n \"require\": {\n \"types\": \"./dist/core/typedefs.d.cts\",\n \"default\": \"./dist/core/typedefs.cjs\"\n },\n \"import\": {\n \"types\": \"./dist/core/typedefs.d.ts\",\n \"default\": \"./dist/core/typedefs.js\"\n }\n },\n \"./*\": {\n \"require\": {\n \"types\": \"./dist/*.d.cts\",\n \"default\": \"./dist/*.cjs\"\n },\n \"import\": {\n \"types\": \"./dist/*.d.ts\",\n \"default\": \"./dist/*.js\"\n }\n }\n },\n \"main\": \"dist/index.cjs\",\n \"module\": \"dist/index.js\",\n \"types\": \"dist/index.d.ts\",\n \"typesVersions\": {\n \"*\": {\n \"astro\": [\"./dist/astro.d.ts\"],\n \"rspack\": [\"./dist/rspack.d.ts\"],\n \"vite\": [\"./dist/vite.d.ts\"],\n \"webpack\": [\"./dist/webpack.d.ts\"],\n \"rollup\": [\"./dist/rollup.d.ts\"],\n \"esbuild\": [\"./dist/esbuild.d.ts\"],\n \"nuxt\": [\"./dist/nuxt.d.ts\"],\n \"farm\": [\"./dist/farm.d.ts\"],\n \"types\": [\"./dist/core/types.d.ts\"],\n \"typedefs\": [\"./dist/core/typedefs.d.ts\"],\n \"*\": [\"./dist/*\"]\n }\n },\n \"files\": [\"dist\", \"*.md\"],\n \"scripts\": {\n \"build\": \"tsup\",\n \"dev\": \"tsup --watch\",\n \"type-check\": \"tsc -p tsconfig.check.json\"\n },\n \"peerDependencies\": {\n \"@farmfe/core\": \">=1\",\n \"@nuxt/kit\": \"^3\",\n \"@nuxt/schema\": \"^3\",\n \"esbuild\": \"*\",\n \"rollup\": \"^3\",\n \"vite\": \"^6\",\n \"webpack\": \"^4 || ^5\"\n },\n \"peerDependenciesMeta\": {\n \"@farmfe/core\": {\n \"optional\": true\n },\n \"@nuxt/kit\": {\n \"optional\": true\n },\n \"@nuxt/schema\": {\n \"optional\": true\n },\n \"esbuild\": {\n \"optional\": true\n },\n \"rollup\": {\n \"optional\": true\n },\n \"vite\": {\n \"optional\": true\n },\n \"webpack\": {\n \"optional\": true\n }\n },\n \"devDependencies\": {\n \"@luckycatfactory/esbuild-graphql-loader\": \"^3.8.1\",\n \"@nuxt/kit\": \"^3.15.1\",\n \"@nuxt/schema\": \"^3.15.1\",\n \"@tsconfig/node20\": \"^20.1.4\",\n \"@types/node\": \"^22.10.5\",\n \"bumpp\": \"^9.9.2\",\n \"chalk\": \"^5.4.1\",\n \"esno\": \"^4.8.0\",\n \"npm-check-updates\": \"^17.1.13\",\n \"npm-run-all2\": \"^7.0.2\",\n \"rollup\": \"^4.30.0\",\n \"terser\": \"^5.37.0\",\n \"tsup\": \"^8.3.5\",\n \"vite\": \"^6.0.7\",\n \"vitest\": \"^2.1.8\",\n \"webpack\": \"^5.97.1\"\n },\n \"dependencies\": {\n \"glob\": \"^11.0.0\",\n \"graphql\": \"^16.10.0\",\n \"graphql-tag\": \"^2.12.6\",\n \"unplugin\": \"^2.1.2\"\n }\n}\n","import { name } from '../../package.json';\n\nconst exportSpecifier = 'typedefs';\n\nexport const virtualModuleId = `${name}/${exportSpecifier}`;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e=require("./chunk-PK6SKIKE.cjs"),n=require("node:path"),t=require("fs"),a=require("graphql-tag"),r=require("readline"),o=require("path"),i=require("glob");function l(e){return e&&e.__esModule?e:{default:e}}var s=l(n),u=l(t),d=l(a),c=l(r),m=l(o),p=e.__name(((e,n)=>{const t=n?n(e):e;return JSON.stringify(t,((e,n)=>void 0===n?"__undefined":n)).replace(/"__undefined"/g,"undefined")}),"generateDocumentNodeString"),f=e.__name(((n,t)=>{const a=new Set,r=[],o=e.__name((e=>{a.has(e)||(a.add(e),e.imports.forEach((e=>{const n=t[e.absolutePath];o(n)})),r.unshift(e))}),"visitFile");return n.forEach(o),r}),"topologicallySortParsedFiles"),h=e.__name((n=>new Promise((t=>{const a=c.default.createInterface({input:u.default.createReadStream(n)});let r="";const o=[];let i=!1;const l=e.__name(((e,t)=>{const a=t.replace(e,""),r=a.replace(/"|'/g,""),i=m.default.join(m.default.dirname(n),r);o.push({absolutePath:i,relativePath:a})}),"parseImportAndCapture");a.on("line",(e=>{e.startsWith("#import ")?l("#import ",e):e.startsWith("# import ")?l("# import ",e):i?r+=e+"\n":"#"!==e[0]&&""!==e&&(i=!0,r+=e+"\n")})),a.on("close",(()=>{t({body:r.trim(),filePath:n,imports:o})}))}))),"parseGraphQLFile"),_=e.__name((n=>{const t={},a=[],r=new Set,o=e.__name((e=>t[e]?Promise.resolve(null):new Promise((n=>{h(e).then((e=>{t[e.filePath]=e,e.imports.forEach((e=>{r.has(e.absolutePath)||(r.add(e.absolutePath),a.push(o(e.absolutePath)))}));const i=a.shift();return i?i.then(n):n(null)}))}))),"visitAndParse");return o(n).then((()=>f(Object.values(t),t).reduce(((e,n)=>n.body+"\n\n"+e),"")))}),"generateGraphQLString"),g=e.__name(((e,n,t)=>{const a={kind:"Document",definitions:[e,...n]};return p(a,t)}),"generateDocumentNodeStringForOperationDefinition"),P=e.__name((n=>e.__name(((e,n)=>(e.forEach((e=>{"FragmentDefinition"===e.kind&&(n[e.name.value]=e)})),n)),"accumulateAllFragments")(n.definitions,{})),"collectAllFragmentDefinitions"),S=e.__name(((n,t)=>{const a=[],r=e.__name((e=>{if("FragmentSpread"===e.kind){const n=t[e.name.value],r=S(n,t);a.push(...r,e.name.value)}}),"handleSelectionNode");return"OperationDefinition"===n.kind?n.selectionSet.selections.forEach((e=>{var n;"Field"===e.kind&&(null==(n=e.selectionSet)||n.selections.forEach(r))})):n.selectionSet.selections.forEach(r),a}),"collectAllFragmentReferences"),v=e.__name(((e,n)=>{const t=d.default(e),a=p(t,n),r=P(t),o=t.definitions.reduce(((e,t)=>{if("OperationDefinition"===t.kind&&t.name&&t.name.value){const a=t.name.value,o=S(t,r).map((e=>{const n=r[e];if(!n)throw new Error(`Expected to find fragment definition for ${e}`);return n})),i=g(t,o,n);e.push(`export const ${a} = ${i};`)}return e}),[`const documentNode = ${a};`]);return o.push("export default documentNode;"),o.join("\n")}),"generateContentsFromGraphqlString"),F=e.__name((async e=>(await i.glob(e.globPattern,{ignore:e.globIgnore})).map(((e,n)=>({path:s.default.join(process.cwd(),e).replace(/\\/g,"/"),name:`gql_${n}`})))),"findGraphQLFiles"),b=e.__name((e=>[...e.map((e=>`import ${e.name} from '${e.path}';`)),`export default ${`[${e.map((e=>e.name)).join(", ")}]`};`].join("\n")),"generateTypedefsFile"),q=e.__name((async(e,n)=>{const t=await F(e),a=b(t);return n.debug(`Typedefs: \`${a}\``),{code:a,map:null}}),"loadVirtualModule"),w=e.__name((async(e,n,t)=>{if(e.startsWith("\0")&&e.endsWith(".graphql")){const t=e.slice(1),a=await _(t);return{code:v(a,n.mapDocumentNode),map:null}}}),"loadGraphqlModule");exports.findGraphQLFiles=F,exports.loadGraphqlModule=w,exports.loadVirtualModule=q;//# sourceMappingURL=chunk-PHIKG3MI.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../node_modules/.pnpm/@luckycatfactory+esbuild-graphql-loader@3.8.1_esbuild@0.24.2_graphql-tag@2.12.6_graphql@16.10.0__graphql@16.10.0/node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AK,EAAG,CAAA,QAAA,CAAS,UAAU,CAAG,EAAA;AAClD,IAAM,MAAA,MAAA,GAAS,EAAG,CAAA,KAAA,CAAM,CAAC,CAAA;AACzB,IAAM,MAAA,aAAA,GAAgB,MAAM,qBAAA,CAAsB,MAAM,CAAA;AACxD,IAAA,MAAM,IAAO,GAAA,iCAAA,CAAkC,aAAe,EAAA,OAAA,CAAQ,eAAe,CAAA;AACrF,IAAO,OAAA;AAAA,MACL,IAAA;AAAA,MACA,GAAK,EAAA;AAAA,KACP;AAAA;AAEF,EAAO,OAAA,SAAA;AACT,CAXiC,EAAA,mBAAA","file":"chunk-PHIKG3MI.cjs","sourcesContent":["// src/index.ts\nimport fs2 from \"fs\";\nimport gql from \"graphql-tag\";\nimport readline2 from \"readline\";\nimport path2 from \"path\";\nvar generateDocumentNodeString = (graphqlDocument, mapDocumentNode) => {\n const documentNodeToUse = mapDocumentNode ? mapDocumentNode(graphqlDocument) : graphqlDocument;\n return JSON.stringify(documentNodeToUse, (key, value) => value === void 0 ? \"__undefined\" : value).replace(/\"__undefined\"/g, \"undefined\");\n};\nvar topologicallySortParsedFiles = (parsedFiles, cache) => {\n const visitedFiles = new Set();\n const sorted = [];\n const visitFile = (file) => {\n if (visitedFiles.has(file))\n return;\n visitedFiles.add(file);\n file.imports.forEach((importFileEntry) => {\n const importedFile = cache[importFileEntry.absolutePath];\n visitFile(importedFile);\n });\n sorted.unshift(file);\n };\n parsedFiles.forEach(visitFile);\n return sorted;\n};\nvar parseGraphQLFile = (filePath) => new Promise((resolve) => {\n const readInterface = readline2.createInterface({\n input: fs2.createReadStream(filePath)\n });\n let body = \"\";\n const imports = [];\n let hasExhaustedImports = false;\n const parseImportAndCapture = (importCommentPrefix, line) => {\n const relativePath = line.replace(importCommentPrefix, \"\");\n const relativePathWithoutQuotations = relativePath.replace(/\"|'/g, \"\");\n const absolutePath = path2.join(path2.dirname(filePath), relativePathWithoutQuotations);\n imports.push({\n absolutePath,\n relativePath\n });\n };\n readInterface.on(\"line\", (line) => {\n if (line.startsWith(\"#import \")) {\n parseImportAndCapture(\"#import \", line);\n } else if (line.startsWith(\"# import \")) {\n parseImportAndCapture(\"# import \", line);\n } else if (hasExhaustedImports) {\n body += line + \"\\n\";\n } else if (line[0] !== \"#\" && line !== \"\") {\n hasExhaustedImports = true;\n body += line + \"\\n\";\n }\n });\n readInterface.on(\"close\", () => {\n resolve({body: body.trim(), filePath, imports});\n });\n});\nvar generateGraphQLString = (entryPointPath) => {\n const cache = {};\n const parsePromises = [];\n const seenImportPaths = new Set();\n const visitAndParse = (filePath) => {\n if (cache[filePath])\n return Promise.resolve(null);\n return new Promise((resolve) => {\n parseGraphQLFile(filePath).then((parsedFile) => {\n cache[parsedFile.filePath] = parsedFile;\n parsedFile.imports.forEach((importEntry) => {\n if (!seenImportPaths.has(importEntry.absolutePath)) {\n seenImportPaths.add(importEntry.absolutePath);\n parsePromises.push(visitAndParse(importEntry.absolutePath));\n }\n });\n const nextPromise = parsePromises.shift();\n if (nextPromise) {\n return nextPromise.then(resolve);\n }\n return resolve(null);\n });\n });\n };\n return visitAndParse(entryPointPath).then(() => {\n const files = topologicallySortParsedFiles(Object.values(cache), cache);\n const graphqlString = files.reduce((accumulator, file) => {\n return file.body + \"\\n\\n\" + accumulator;\n }, \"\");\n return graphqlString;\n });\n};\nvar generateDocumentNodeStringForOperationDefinition = (operationDefinition, fragments, mapDocumentNode) => {\n const operationDocument = {\n kind: \"Document\",\n definitions: [operationDefinition, ...fragments]\n };\n return generateDocumentNodeString(operationDocument, mapDocumentNode);\n};\nvar collectAllFragmentDefinitions = (documentNode) => {\n const accumulateAllFragments = (nodes, accumulator) => {\n nodes.forEach((node) => {\n if (node.kind === \"FragmentDefinition\") {\n accumulator[node.name.value] = node;\n }\n });\n return accumulator;\n };\n return accumulateAllFragments(documentNode.definitions, {});\n};\nvar collectAllFragmentReferences = (node, allFragments) => {\n const references = [];\n const handleSelectionNode = (selection) => {\n if (selection.kind === \"FragmentSpread\") {\n const fragment = allFragments[selection.name.value];\n const innerFragmentReferences = collectAllFragmentReferences(fragment, allFragments);\n references.push(...innerFragmentReferences, selection.name.value);\n }\n };\n if (node.kind === \"OperationDefinition\") {\n node.selectionSet.selections.forEach((selection) => {\n var _a;\n if (selection.kind === \"Field\") {\n (_a = selection.selectionSet) == null ? void 0 : _a.selections.forEach(handleSelectionNode);\n }\n });\n } else {\n node.selectionSet.selections.forEach(handleSelectionNode);\n }\n return references;\n};\nvar generateContentsFromGraphqlString = (graphqlString, mapDocumentNode) => {\n const graphqlDocument = gql(graphqlString);\n const documentNodeAsString = generateDocumentNodeString(graphqlDocument, mapDocumentNode);\n const allFragments = collectAllFragmentDefinitions(graphqlDocument);\n const lines = graphqlDocument.definitions.reduce((accumulator, definition) => {\n if (definition.kind === \"OperationDefinition\" && definition.name && definition.name.value) {\n const name = definition.name.value;\n const fragmentsForOperation = collectAllFragmentReferences(definition, allFragments);\n const fragments = fragmentsForOperation.map((fragmentForOperation) => {\n const fragment = allFragments[fragmentForOperation];\n if (!fragment) {\n throw new Error(`Expected to find fragment definition for ${fragmentForOperation}`);\n }\n return fragment;\n });\n const operationDocumentString = generateDocumentNodeStringForOperationDefinition(definition, fragments, mapDocumentNode);\n accumulator.push(`export const ${name} = ${operationDocumentString};`);\n }\n return accumulator;\n }, [`const documentNode = ${documentNodeAsString};`]);\n lines.push(`export default documentNode;`);\n return lines.join(\"\\n\");\n};\nvar graphqlLoaderPlugin = (options = {}) => ({\n name: \"graphql-loader\",\n setup(build) {\n build.onLoad({filter: options.filterRegex || /\\.graphql$|\\.gql$/}, (args) => generateGraphQLString(args.path).then((graphqlString) => ({\n contents: generateContentsFromGraphqlString(graphqlString, options.mapDocumentNode)\n })));\n }\n});\nvar src_default = graphqlLoaderPlugin;\nexport {\n src_default as default,\n generateContentsFromGraphqlString,\n generateGraphQLString\n};\n","import path from 'node:path';\nimport { generateContentsFromGraphqlString, generateGraphQLString } from '@luckycatfactory/esbuild-graphql-loader';\nimport { glob } from 'glob';\nimport type { DocumentNode } from 'graphql';\nimport type { ILogger } from './types';\n\ntype GraphqlFile = {\n path: string;\n name: string;\n};\n\nexport const findGraphQLFiles = async (options: { globPattern: string; globIgnore: string }): Promise<GraphqlFile[]> => {\n const files = await glob(options.globPattern, { ignore: options.globIgnore });\n return files.map((file, index) => ({\n path: path.join(process.cwd(), file).replace(/\\\\/g, '/'),\n name: `gql_${index}`,\n }));\n};\n\nconst generateTypedefsFile = (files: GraphqlFile[]) => {\n const importStatements = files.map((f) => `import ${f.name} from '${f.path}';`);\n\n const documentsArray = `[${files.map((f) => f.name).join(', ')}]`;\n\n const code = [...importStatements, `export default ${documentsArray};`];\n return code.join('\\n');\n};\n\ntype TransformResult =\n | {\n code: string;\n map: null;\n }\n | null\n | undefined;\n\nexport const loadVirtualModule = async (options: { globPattern: string; globIgnore: string }, logger: ILogger): Promise<TransformResult> => {\n const files = await findGraphQLFiles(options);\n const code = generateTypedefsFile(files);\n logger.debug(`Typedefs: \\`${code}\\``);\n return { code, map: null };\n};\n\nexport const loadGraphqlModule = async (id: string, options: { mapDocumentNode?: (documentNode: DocumentNode) => DocumentNode }, logger: ILogger): Promise<TransformResult> => {\n if (id.startsWith('\\0') && id.endsWith('.graphql')) {\n const realId = id.slice(1);\n const graphqlString = await generateGraphQLString(realId);\n const code = generateContentsFromGraphqlString(graphqlString, options.mapDocumentNode);\n return {\n code,\n map: null,\n };\n }\n return undefined;\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";exports.defaults={globPattern:"**/*.graphql",globIgnore:"**/node_modules/**",ignoreErrors:!1,debug:!1};//# sourceMappingURL=chunk-UQ7VVNQE.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/defaults.ts"],"names":[],"mappings":";AAEO,IAAM,QAAW,GAAA;AAAA,EACtB,WAAa,EAAA,cAAA;AAAA,EACb,UAAY,EAAA,oBAAA;AAAA,EACZ,YAAc,EAAA,KAAA;AAAA,EACd,KAAO,EAAA;AACT","file":"chunk-UQ7VVNQE.cjs","sourcesContent":["import type { Options } from './types';\n\nexport const defaults = {\n globPattern: '**/*.graphql',\n globIgnore: '**/node_modules/**',\n ignoreErrors: false,\n debug: false,\n} as const satisfies Options;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e=require("./chunk-UQ7VVNQE.cjs"),r=require("./chunk-PHIKG3MI.cjs"),o=require("./chunk-M2KOJHTB.cjs"),t=require("./chunk-PK6SKIKE.cjs"),l=require("node:util"),n=require("glob"),i=require("unplugin"),u=t.__name((e=>`\0${e}`),"resolveVirtualId"),a=t.__name((i=>{const a={...e.defaults,...i},d={debug:a.debug?(e,...r)=>{const o="object"==typeof e?l.inspect(e,{depth:null,colors:!0}):e;console.debug("[graphql]",o,...r)}:()=>{},error:t.__name(((e,...r)=>{const o="object"==typeof e?l.inspect(e,{depth:null,colors:!0}):e;console.error("[graphql]",o,...r)}),"error")};let s=[];const p=[];let c=!1;return d.debug({options:a}),{name:"unplugin-graphql",enforce:"pre",buildStart:t.__name((async()=>{s=await n.glob(a.globPattern,{ignore:a.globIgnore}),d.debug("Matched GraphQL files:",s)}),"buildStart"),resolveId:e=>e===o.virtualModuleId||e.endsWith(".graphql")?u(e):void 0,load:t.__name((async e=>{if(e===u(o.virtualModuleId))return c=!0,await r.loadVirtualModule(a,d);const t=await r.loadGraphqlModule(e,a,d);return void 0!==t?(p.push(e),t):void 0}),"load"),buildEnd:t.__name((()=>{if(d.debug("Build end",{graphqlMatched:s,graphqlImports:p,importedTypedefs:c}),!a.ignoreErrors){if(0===s.length)throw new Error(`No GraphQL files found for the pattern: ${a.globPattern}`);if(p.length!==s.length)throw new Error("Some GraphQL files were not imported");if(!c)throw new Error("Typedefs not imported. Make sure to import from @shellicar/build-graphql/typedefs")}}),"buildEnd")}}),"graphqlPluginFactory"),d=i.createUnplugin(a);exports.plugin=d;//# sourceMappingURL=chunk-WQ3PTPJG.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/index.ts"],"names":["__name","defaults","inspect","glob","virtualModuleId","loadVirtualModule","loadGraphqlModule","createUnplugin"],"mappings":"0SASA,IAAM,gBAAmB,mBAAAA,wBAAA,CAAA,CAAC,EAAe,KAAA,CAAA,EAAA,EAAK,EAAE,CAAvB,CAAA,EAAA,kBAAA,CAAA;AAEzB,IAAM,oBAAA,6CAAkD,YAAiB,KAAA;AACvE,EAAA,MAAM,OAAU,GAAA;AAAA,IACd,GAAGC,0BAAA;AAAA,IACH,GAAG;AAAA,GACL;AACA,EAAA,MAAM,KAAQ,GAAA,OAAA,CAAQ,KAClB,GAAA,CAAC,YAAqB,cAA8B,KAAA;AAClD,IAAA,MAAM,gBAAmB,GAAA,OAAO,OAAY,KAAA,QAAA,GAAWC,iBAAQ,CAAA,OAAA,EAAS,EAAE,KAAA,EAAO,IAAM,EAAA,MAAA,EAAQ,IAAK,EAAC,CAAI,GAAA,OAAA;AACzG,IAAA,OAAA,CAAQ,KAAM,CAAA,WAAA,EAAa,gBAAkB,EAAA,GAAG,cAAc,CAAA;AAAA,MAEhE,MAAM;AAAA,GAAC;AAEX,EAAM,MAAA,KAAA,mBAASF,wBAAA,CAAA,CAAA,OAAA,EAAA,GAAqB,cAA8B,KAAA;AAChE,IAAA,MAAM,gBAAmB,GAAA,OAAO,OAAY,KAAA,QAAA,GAAWE,iBAAQ,CAAA,OAAA,EAAS,EAAE,KAAA,EAAO,IAAM,EAAA,MAAA,EAAQ,IAAK,EAAC,CAAI,GAAA,OAAA;AACzG,IAAA,OAAA,CAAQ,KAAM,CAAA,WAAA,EAAa,gBAAkB,EAAA,GAAG,cAAc,CAAA;AAAA,GAFlD,EAAA,OAAA,CAAA;AAKd,EAAA,MAAM,MAAkB,GAAA;AAAA,IACtB,KAAA;AAAA,IACA;AAAA,GACF;AAEA,EAAA,IAAI,iBAA2B,EAAC;AAChC,EAAA,MAAM,iBAA2B,EAAC;A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,CAAC,QAAQ,YAAc,EAAA;AACzB,QAAI,IAAA,cAAA,CAAe,WAAW,CAAG,EAAA;AAC/B,UAAA,MAAM,IAAI,KAAA,CAAM,CAA2C,wCAAA,EAAA,OAAA,CAAQ,WAAW,CAAE,CAAA,CAAA;AAAA;AAElF,QAAI,IAAA,cAAA,CAAe,MAAW,KAAA,cAAA,CAAe,MAAQ,EAAA;AACnD,UAAM,MAAA,IAAI,MAAM,sCAAsC,CAAA;AAAA;AAExD,QAAA,IAAI,CAAC,gBAAkB,EAAA;AACrB,UAAM,MAAA,IAAI,MAAM,mFAAmF,CAAA;AAAA;AACrG;AACF,KAhBQ,EAAA,UAAA;AAAA,GAkBZ;AACF,CAxEuD,EAAA,sBAAA,CAAA;AA0E1C,IAAA,MAAA,GAASO,wBAAe,oBAAoB","file":"chunk-WQ3PTPJG.cjs","sourcesContent":["import { inspect } from 'node:util';\nimport { glob } from 'glob';\nimport type { UnpluginFactory } from 'unplugin';\nimport { createUnplugin } from 'unplugin';\nimport { defaults } from './defaults';\nimport { loadGraphqlModule, loadVirtualModule } from './graphql';\nimport { virtualModuleId } from './module';\nimport type { ILogger, Options } from './types';\n\nconst resolveVirtualId = (id: string) => `\\0${id}`;\n\nconst graphqlPluginFactory: UnpluginFactory<Options> = (inputOptions) => {\n const options = {\n ...defaults,\n ...inputOptions,\n };\n const debug = options.debug\n ? (message: unknown, ...optionalParams: unknown[]) => {\n const formattedMessage = typeof message === 'object' ? inspect(message, { depth: null, colors: true }) : message;\n console.debug('[graphql]', formattedMessage, ...optionalParams);\n }\n : () => {};\n\n const error = (message: unknown, ...optionalParams: unknown[]) => {\n const formattedMessage = typeof message === 'object' ? inspect(message, { depth: null, colors: true }) : message;\n console.error('[graphql]', formattedMessage, ...optionalParams);\n };\n\n const logger: ILogger = {\n debug,\n error,\n };\n\n let graphqlMatched: string[] = [];\n const graphqlImports: string[] = [];\n let importedTypedefs = false;\n logger.debug({ options });\n\n return {\n name: 'unplugin-graphql',\n enforce: 'pre',\n buildStart: async () => {\n graphqlMatched = await glob(options.globPattern, { ignore: options.globIgnore });\n logger.debug('Matched GraphQL files:', graphqlMatched);\n },\n resolveId(id) {\n if (id === virtualModuleId) {\n return resolveVirtualId(id);\n }\n if (id.endsWith('.graphql')) {\n return resolveVirtualId(id);\n }\n },\n load: async (id) => {\n if (id === resolveVirtualId(virtualModuleId)) {\n importedTypedefs = true;\n return await loadVirtualModule(options, logger);\n }\n const result = await loadGraphqlModule(id, options, logger);\n if (result !== undefined) {\n graphqlImports.push(id);\n return result;\n }\n },\n buildEnd: () => {\n logger.debug('Build end', {\n graphqlMatched,\n graphqlImports,\n importedTypedefs,\n });\n if (!options.ignoreErrors) {\n if (graphqlMatched.length === 0) {\n throw new Error(`No GraphQL files found for the pattern: ${options.globPattern}`);\n }\n if (graphqlImports.length !== graphqlMatched.length) {\n throw new Error('Some GraphQL files were not imported');\n }\n if (!importedTypedefs) {\n throw new Error('Typedefs not imported. Make sure to import from @shellicar/build-graphql/typedefs');\n }\n }\n },\n };\n};\n\nexport const plugin = createUnplugin(graphqlPluginFactory);\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{defaults as r}from"./chunk-7BERUFQQ.js";import{loadVirtualModule as o,loadGraphqlModule as e}from"./chunk-MROI2TT6.js";import{virtualModuleId as t}from"./chunk-OSLESBPI.js";import{__name as n}from"./chunk-7QVYU63E.js";import{inspect as l}from"node:util";import{glob as i}from"glob";import{createUnplugin as p}from"unplugin";var d=n((r=>`\0${r}`),"resolveVirtualId"),a=p(n((p=>{const a={...r,...p},u={debug:a.debug?(r,...o)=>{const e="object"==typeof r?l(r,{depth:null,colors:!0}):r;console.debug("[graphql]",e,...o)}:()=>{},error:n(((r,...o)=>{const e="object"==typeof r?l(r,{depth:null,colors:!0}):r;console.error("[graphql]",e,...o)}),"error")};let s=[];const h=[];let g=!1;return u.debug({options:a}),{name:"unplugin-graphql",enforce:"pre",buildStart:n((async()=>{s=await i(a.globPattern,{ignore:a.globIgnore}),u.debug("Matched GraphQL files:",s)}),"buildStart"),resolveId:r=>r===t||r.endsWith(".graphql")?d(r):void 0,load:n((async r=>{if(r===d(t))return g=!0,await o(a,u);const n=await e(r,a,u);return void 0!==n?(h.push(r),n):void 0}),"load"),buildEnd:n((()=>{if(u.debug("Build end",{graphqlMatched:s,graphqlImports:h,importedTypedefs:g}),!a.ignoreErrors){if(0===s.length)throw new Error(`No GraphQL files found for the pattern: ${a.globPattern}`);if(h.length!==s.length)throw new Error("Some GraphQL files were not imported");if(!g)throw new Error("Typedefs not imported. Make sure to import from @shellicar/build-graphql/typedefs")}}),"buildEnd")}}),"graphqlPluginFactory"));export{a as plugin};//# sourceMappingURL=chunk-YUBBVNLZ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/index.ts"],"names":[],"mappings":"0SASA,IAAM,gBAAmB,mBAAA,MAAA,CAAA,CAAC,EAAe,KAAA,CAAA,EAAA,EAAK,EAAE,CAAvB,CAAA,EAAA,kBAAA,CAAA;AAEzB,IAAM,oBAAA,2BAAkD,YAAiB,KAAA;AACvE,EAAA,MAAM,OAAU,GAAA;AAAA,IACd,GAAG,QAAA;AAAA,IACH,GAAG;AAAA,GACL;AACA,EAAA,MAAM,KAAQ,GAAA,OAAA,CAAQ,KAClB,GAAA,CAAC,YAAqB,cAA8B,KAAA;AAClD,IAAA,MAAM,gBAAmB,GAAA,OAAO,OAAY,KAAA,QAAA,GAAW,OAAQ,CAAA,OAAA,EAAS,EAAE,KAAA,EAAO,IAAM,EAAA,MAAA,EAAQ,IAAK,EAAC,CAAI,GAAA,OAAA;AACzG,IAAA,OAAA,CAAQ,KAAM,CAAA,WAAA,EAAa,gBAAkB,EAAA,GAAG,cAAc,CAAA;AAAA,MAEhE,MAAM;AAAA,GAAC;AAEX,EAAM,MAAA,KAAA,mBAAS,MAAA,CAAA,CAAA,OAAA,EAAA,GAAqB,cAA8B,KAAA;AAChE,IAAA,MAAM,gBAAmB,G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,MAAA,MAAM,MAAS,GAAA,MAAM,iBAAkB,CAAA,EAAA,EAAI,SAAS,MAAM,CAAA;AAC1D,MAAA,IAAI,WAAW,SAAW,EAAA;AACxB,QAAA,cAAA,CAAe,KAAK,EAAE,CAAA;AACtB,QAAO,OAAA,MAAA;AAAA;AACT,KATI,EAAA,MAAA,CAAA;AAAA,IAWN,0BAAgB,MAAA,CAAA,MAAA;AACd,MAAA,MAAA,CAAO,MAAM,WAAa,EAAA;AAAA,QACxB,cAAA;AAAA,QACA,cAAA;AAAA,QACA;AAAA,OACD,CAAA;AACD,MAAI,IAAA,CAAC,QAAQ,YAAc,EAAA;AACzB,QAAI,IAAA,cAAA,CAAe,WAAW,CAAG,EAAA;AAC/B,UAAA,MAAM,IAAI,KAAA,CAAM,CAA2C,wCAAA,EAAA,OAAA,CAAQ,WAAW,CAAE,CAAA,CAAA;AAAA;AAElF,QAAI,IAAA,cAAA,CAAe,MAAW,KAAA,cAAA,CAAe,MAAQ,EAAA;AACnD,UAAM,MAAA,IAAI,MAAM,sCAAsC,CAAA;AAAA;AAExD,QAAA,IAAI,CAAC,gBAAkB,EAAA;AACrB,UAAM,MAAA,IAAI,MAAM,mFAAmF,CAAA;AAAA;AACrG;AACF,KAhBQ,EAAA,UAAA;AAAA,GAkBZ;AACF,CAxEuD,EAAA,sBAAA,CAAA;AA0E1C,IAAA,MAAA,GAAS,eAAe,oBAAoB","file":"chunk-YUBBVNLZ.js","sourcesContent":["import { inspect } from 'node:util';\nimport { glob } from 'glob';\nimport type { UnpluginFactory } from 'unplugin';\nimport { createUnplugin } from 'unplugin';\nimport { defaults } from './defaults';\nimport { loadGraphqlModule, loadVirtualModule } from './graphql';\nimport { virtualModuleId } from './module';\nimport type { ILogger, Options } from './types';\n\nconst resolveVirtualId = (id: string) => `\\0${id}`;\n\nconst graphqlPluginFactory: UnpluginFactory<Options> = (inputOptions) => {\n const options = {\n ...defaults,\n ...inputOptions,\n };\n const debug = options.debug\n ? (message: unknown, ...optionalParams: unknown[]) => {\n const formattedMessage = typeof message === 'object' ? inspect(message, { depth: null, colors: true }) : message;\n console.debug('[graphql]', formattedMessage, ...optionalParams);\n }\n : () => {};\n\n const error = (message: unknown, ...optionalParams: unknown[]) => {\n const formattedMessage = typeof message === 'object' ? inspect(message, { depth: null, colors: true }) : message;\n console.error('[graphql]', formattedMessage, ...optionalParams);\n };\n\n const logger: ILogger = {\n debug,\n error,\n };\n\n let graphqlMatched: string[] = [];\n const graphqlImports: string[] = [];\n let importedTypedefs = false;\n logger.debug({ options });\n\n return {\n name: 'unplugin-graphql',\n enforce: 'pre',\n buildStart: async () => {\n graphqlMatched = await glob(options.globPattern, { ignore: options.globIgnore });\n logger.debug('Matched GraphQL files:', graphqlMatched);\n },\n resolveId(id) {\n if (id === virtualModuleId) {\n return resolveVirtualId(id);\n }\n if (id.endsWith('.graphql')) {\n return resolveVirtualId(id);\n }\n },\n load: async (id) => {\n if (id === resolveVirtualId(virtualModuleId)) {\n importedTypedefs = true;\n return await loadVirtualModule(options, logger);\n }\n const result = await loadGraphqlModule(id, options, logger);\n if (result !== undefined) {\n graphqlImports.push(id);\n return result;\n }\n },\n buildEnd: () => {\n logger.debug('Build end', {\n graphqlMatched,\n graphqlImports,\n importedTypedefs,\n });\n if (!options.ignoreErrors) {\n if (graphqlMatched.length === 0) {\n throw new Error(`No GraphQL files found for the pattern: ${options.globPattern}`);\n }\n if (graphqlImports.length !== graphqlMatched.length) {\n throw new Error('Some GraphQL files were not imported');\n }\n if (!importedTypedefs) {\n throw new Error('Typedefs not imported. Make sure to import from @shellicar/build-graphql/typedefs');\n }\n }\n },\n };\n};\n\nexport const plugin = createUnplugin(graphqlPluginFactory);\n"]}
|
package/dist/core/defaults.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("../chunk-
|
|
1
|
+
"use strict";var e=require("../chunk-UQ7VVNQE.cjs");require("../chunk-PK6SKIKE.cjs"),Object.defineProperty(exports,"defaults",{enumerable:!0,get:function(){return e.defaults}});//# sourceMappingURL=defaults.cjs.map
|
package/dist/core/defaults.d.cts
CHANGED
package/dist/core/defaults.d.ts
CHANGED
package/dist/core/defaults.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{defaults}from"../chunk-
|
|
1
|
+
export{defaults}from"../chunk-7BERUFQQ.js";import"../chunk-7QVYU63E.js";//# sourceMappingURL=defaults.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e=require("../chunk-PHIKG3MI.cjs");require("../chunk-PK6SKIKE.cjs"),Object.defineProperty(exports,"findGraphQLFiles",{enumerable:!0,get:function(){return e.findGraphQLFiles}}),Object.defineProperty(exports,"loadGraphqlModule",{enumerable:!0,get:function(){return e.loadGraphqlModule}}),Object.defineProperty(exports,"loadVirtualModule",{enumerable:!0,get:function(){return e.loadVirtualModule}});//# sourceMappingURL=graphql.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"graphql.cjs"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { DocumentNode } from 'graphql';
|
|
2
|
+
import { ILogger } from './types.cjs';
|
|
3
|
+
|
|
4
|
+
type GraphqlFile = {
|
|
5
|
+
path: string;
|
|
6
|
+
name: string;
|
|
7
|
+
};
|
|
8
|
+
declare const findGraphQLFiles: (options: {
|
|
9
|
+
globPattern: string;
|
|
10
|
+
globIgnore: string;
|
|
11
|
+
}) => Promise<GraphqlFile[]>;
|
|
12
|
+
type TransformResult = {
|
|
13
|
+
code: string;
|
|
14
|
+
map: null;
|
|
15
|
+
} | null | undefined;
|
|
16
|
+
declare const loadVirtualModule: (options: {
|
|
17
|
+
globPattern: string;
|
|
18
|
+
globIgnore: string;
|
|
19
|
+
}, logger: ILogger) => Promise<TransformResult>;
|
|
20
|
+
declare const loadGraphqlModule: (id: string, options: {
|
|
21
|
+
mapDocumentNode?: (documentNode: DocumentNode) => DocumentNode;
|
|
22
|
+
}, logger: ILogger) => Promise<TransformResult>;
|
|
23
|
+
|
|
24
|
+
export { findGraphQLFiles, loadGraphqlModule, loadVirtualModule };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { DocumentNode } from 'graphql';
|
|
2
|
+
import { ILogger } from './types.js';
|
|
3
|
+
|
|
4
|
+
type GraphqlFile = {
|
|
5
|
+
path: string;
|
|
6
|
+
name: string;
|
|
7
|
+
};
|
|
8
|
+
declare const findGraphQLFiles: (options: {
|
|
9
|
+
globPattern: string;
|
|
10
|
+
globIgnore: string;
|
|
11
|
+
}) => Promise<GraphqlFile[]>;
|
|
12
|
+
type TransformResult = {
|
|
13
|
+
code: string;
|
|
14
|
+
map: null;
|
|
15
|
+
} | null | undefined;
|
|
16
|
+
declare const loadVirtualModule: (options: {
|
|
17
|
+
globPattern: string;
|
|
18
|
+
globIgnore: string;
|
|
19
|
+
}, logger: ILogger) => Promise<TransformResult>;
|
|
20
|
+
declare const loadGraphqlModule: (id: string, options: {
|
|
21
|
+
mapDocumentNode?: (documentNode: DocumentNode) => DocumentNode;
|
|
22
|
+
}, logger: ILogger) => Promise<TransformResult>;
|
|
23
|
+
|
|
24
|
+
export { findGraphQLFiles, loadGraphqlModule, loadVirtualModule };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{findGraphQLFiles,loadGraphqlModule,loadVirtualModule}from"../chunk-MROI2TT6.js";import"../chunk-7QVYU63E.js";//# sourceMappingURL=graphql.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"graphql.js"}
|
package/dist/core/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("../chunk-
|
|
1
|
+
"use strict";var e=require("../chunk-WQ3PTPJG.cjs");require("../chunk-UQ7VVNQE.cjs"),require("../chunk-PHIKG3MI.cjs"),require("../chunk-M2KOJHTB.cjs"),require("../chunk-PK6SKIKE.cjs"),Object.defineProperty(exports,"plugin",{enumerable:!0,get:function(){return e.plugin}});//# sourceMappingURL=index.cjs.map
|
package/dist/core/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{plugin}from"../chunk-
|
|
1
|
+
export{plugin}from"../chunk-YUBBVNLZ.js";import"../chunk-7BERUFQQ.js";import"../chunk-MROI2TT6.js";import"../chunk-OSLESBPI.js";import"../chunk-7QVYU63E.js";//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e=require("../chunk-M2KOJHTB.cjs");require("../chunk-PK6SKIKE.cjs"),Object.defineProperty(exports,"virtualModuleId",{enumerable:!0,get:function(){return e.virtualModuleId}});//# sourceMappingURL=module.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"module.cjs"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{virtualModuleId}from"../chunk-OSLESBPI.js";import"../chunk-7QVYU63E.js";//# sourceMappingURL=module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"module.js"}
|
package/dist/core/types.d.cts
CHANGED
|
@@ -9,15 +9,6 @@ interface Options {
|
|
|
9
9
|
* Glob ignore pattern for graphql files
|
|
10
10
|
*/
|
|
11
11
|
globIgnore?: string;
|
|
12
|
-
/**
|
|
13
|
-
* Root dir to search for graphql files
|
|
14
|
-
* @default process.cwd()
|
|
15
|
-
*/
|
|
16
|
-
rootDir?: string;
|
|
17
|
-
/**
|
|
18
|
-
* Pattern to match the resolved typedefs path
|
|
19
|
-
*/
|
|
20
|
-
typedefsPath?: string;
|
|
21
12
|
/**
|
|
22
13
|
* Ignores errors, otherwise errors will be thrown if graphql files are not found/imported and the typedefs file is not found
|
|
23
14
|
*/
|
|
@@ -31,5 +22,9 @@ interface Options {
|
|
|
31
22
|
*/
|
|
32
23
|
mapDocumentNode?: (documentNode: DocumentNode) => DocumentNode;
|
|
33
24
|
}
|
|
25
|
+
type ILogger = {
|
|
26
|
+
debug: (typeof console)['debug'];
|
|
27
|
+
error: (typeof console)['error'];
|
|
28
|
+
};
|
|
34
29
|
|
|
35
|
-
export type { Options };
|
|
30
|
+
export type { ILogger, Options };
|
package/dist/core/types.d.ts
CHANGED
|
@@ -9,15 +9,6 @@ interface Options {
|
|
|
9
9
|
* Glob ignore pattern for graphql files
|
|
10
10
|
*/
|
|
11
11
|
globIgnore?: string;
|
|
12
|
-
/**
|
|
13
|
-
* Root dir to search for graphql files
|
|
14
|
-
* @default process.cwd()
|
|
15
|
-
*/
|
|
16
|
-
rootDir?: string;
|
|
17
|
-
/**
|
|
18
|
-
* Pattern to match the resolved typedefs path
|
|
19
|
-
*/
|
|
20
|
-
typedefsPath?: string;
|
|
21
12
|
/**
|
|
22
13
|
* Ignores errors, otherwise errors will be thrown if graphql files are not found/imported and the typedefs file is not found
|
|
23
14
|
*/
|
|
@@ -31,5 +22,9 @@ interface Options {
|
|
|
31
22
|
*/
|
|
32
23
|
mapDocumentNode?: (documentNode: DocumentNode) => DocumentNode;
|
|
33
24
|
}
|
|
25
|
+
type ILogger = {
|
|
26
|
+
debug: (typeof console)['debug'];
|
|
27
|
+
error: (typeof console)['error'];
|
|
28
|
+
};
|
|
34
29
|
|
|
35
|
-
export type { Options };
|
|
30
|
+
export type { ILogger, Options };
|
package/dist/esbuild.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("./chunk-
|
|
1
|
+
"use strict";var e=require("./chunk-WQ3PTPJG.cjs");require("./chunk-UQ7VVNQE.cjs"),require("./chunk-PHIKG3MI.cjs"),require("./chunk-M2KOJHTB.cjs"),require("./chunk-PK6SKIKE.cjs");var r=e.plugin.esbuild;module.exports=r,module.exports=exports.default;//# sourceMappingURL=esbuild.cjs.map
|
package/dist/esbuild.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{plugin as r}from"./chunk-
|
|
1
|
+
import{plugin as r}from"./chunk-YUBBVNLZ.js";import"./chunk-7BERUFQQ.js";import"./chunk-MROI2TT6.js";import"./chunk-OSLESBPI.js";import"./chunk-7QVYU63E.js";var o=r.esbuild;export{o as default};//# sourceMappingURL=esbuild.js.map
|
package/dist/farm.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("./chunk-
|
|
1
|
+
"use strict";var e=require("./chunk-WQ3PTPJG.cjs");require("./chunk-UQ7VVNQE.cjs"),require("./chunk-PHIKG3MI.cjs"),require("./chunk-M2KOJHTB.cjs"),require("./chunk-PK6SKIKE.cjs");var r=e.plugin.farm;module.exports=r,module.exports=exports.default;//# sourceMappingURL=farm.cjs.map
|
package/dist/farm.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{plugin as r}from"./chunk-
|
|
1
|
+
import{plugin as r}from"./chunk-YUBBVNLZ.js";import"./chunk-7BERUFQQ.js";import"./chunk-MROI2TT6.js";import"./chunk-OSLESBPI.js";import"./chunk-7QVYU63E.js";var m=r.farm;export{m as default};//# sourceMappingURL=farm.js.map
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";require("./chunk-H44HDUOM.cjs");var e=require("./chunk-
|
|
1
|
+
"use strict";require("./chunk-H44HDUOM.cjs");var e=require("./chunk-WQ3PTPJG.cjs");require("./chunk-UQ7VVNQE.cjs"),require("./chunk-PHIKG3MI.cjs"),require("./chunk-M2KOJHTB.cjs"),require("./chunk-PK6SKIKE.cjs"),module.exports=e.plugin,module.exports=exports.default;//# sourceMappingURL=index.cjs.map
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./chunk-QZKD24XZ.js";export{plugin as default}from"./chunk-
|
|
1
|
+
import"./chunk-QZKD24XZ.js";export{plugin as default}from"./chunk-YUBBVNLZ.js";import"./chunk-7BERUFQQ.js";import"./chunk-MROI2TT6.js";import"./chunk-OSLESBPI.js";import"./chunk-7QVYU63E.js";//# sourceMappingURL=index.js.map
|
package/dist/nuxt.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";require("./chunk-H44HDUOM.cjs");var e=require("./chunk-
|
|
1
|
+
"use strict";require("./chunk-H44HDUOM.cjs");var e=require("./chunk-WQ3PTPJG.cjs");require("./chunk-UQ7VVNQE.cjs"),require("./chunk-PHIKG3MI.cjs"),require("./chunk-M2KOJHTB.cjs"),require("./chunk-PK6SKIKE.cjs"),require("@nuxt/schema");var u=require("@nuxt/kit"),r=u.defineNuxtModule({meta:{name:"nuxt-build-graphql",configKey:"buildGraphql"},setup(r){u.addWebpackPlugin(e.plugin.webpack(r)),u.addVitePlugin(e.plugin.vite(r))}});module.exports=r,module.exports=exports.default;//# sourceMappingURL=nuxt.cjs.map
|
package/dist/nuxt.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/nuxt.ts"],"names":["defineNuxtModule","addWebpackPlugin","plugin","addVitePlugin"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/nuxt.ts"],"names":["defineNuxtModule","addWebpackPlugin","plugin","addVitePlugin"],"mappings":"wRAKA,IAAO,eAAQA,oBAAiB,CAAA;AAAA,EAC9B,IAAM,EAAA;AAAA,IACJ,IAAM,EAAA,oBAAA;AAAA,IACN,SAAW,EAAA;AAAA,GACb;AAAA,EACA,MAAM,OAAkB,EAAA;AACtB,IAAiBC,oBAAA,CAAAC,wBAAA,CAAS,OAAQ,CAAA,OAAO,CAAC,CAAA;AAC1C,IAAcC,iBAAA,CAAAD,wBAAA,CAAS,IAAK,CAAA,OAAO,CAAC,CAAA;AAAA;AAExC,CAAC","file":"nuxt.cjs","sourcesContent":["import '@nuxt/schema';\nimport { addVitePlugin, addWebpackPlugin, defineNuxtModule } from '@nuxt/kit';\nimport unplugin from '.';\nimport type { Options } from './core/types';\n\nexport default defineNuxtModule({\n meta: {\n name: 'nuxt-build-graphql',\n configKey: 'buildGraphql',\n },\n setup(options: Options) {\n addWebpackPlugin(unplugin.webpack(options));\n addVitePlugin(unplugin.vite(options));\n },\n});\n"]}
|
package/dist/nuxt.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./chunk-QZKD24XZ.js";import{plugin as t}from"./chunk-
|
|
1
|
+
import"./chunk-QZKD24XZ.js";import{plugin as t}from"./chunk-YUBBVNLZ.js";import"./chunk-7BERUFQQ.js";import"./chunk-MROI2TT6.js";import"./chunk-OSLESBPI.js";import"./chunk-7QVYU63E.js";import"@nuxt/schema";import{defineNuxtModule as r,addWebpackPlugin as i,addVitePlugin as m}from"@nuxt/kit";var p=r({meta:{name:"nuxt-build-graphql",configKey:"buildGraphql"},setup(r){i(t.webpack(r)),m(t.vite(r))}});export{p as default};//# sourceMappingURL=nuxt.js.map
|
package/dist/nuxt.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/nuxt.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/nuxt.ts"],"names":[],"mappings":"kRAKA,IAAO,eAAQ,gBAAiB,CAAA;AAAA,EAC9B,IAAM,EAAA;AAAA,IACJ,IAAM,EAAA,oBAAA;AAAA,IACN,SAAW,EAAA;AAAA,GACb;AAAA,EACA,MAAM,OAAkB,EAAA;AACtB,IAAiB,gBAAA,CAAA,MAAA,CAAS,OAAQ,CAAA,OAAO,CAAC,CAAA;AAC1C,IAAc,aAAA,CAAA,MAAA,CAAS,IAAK,CAAA,OAAO,CAAC,CAAA;AAAA;AAExC,CAAC","file":"nuxt.js","sourcesContent":["import '@nuxt/schema';\nimport { addVitePlugin, addWebpackPlugin, defineNuxtModule } from '@nuxt/kit';\nimport unplugin from '.';\nimport type { Options } from './core/types';\n\nexport default defineNuxtModule({\n meta: {\n name: 'nuxt-build-graphql',\n configKey: 'buildGraphql',\n },\n setup(options: Options) {\n addWebpackPlugin(unplugin.webpack(options));\n addVitePlugin(unplugin.vite(options));\n },\n});\n"]}
|
package/dist/rollup.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("./chunk-
|
|
1
|
+
"use strict";var e=require("./chunk-WQ3PTPJG.cjs");require("./chunk-UQ7VVNQE.cjs"),require("./chunk-PHIKG3MI.cjs"),require("./chunk-M2KOJHTB.cjs"),require("./chunk-PK6SKIKE.cjs");var r=e.plugin.rollup;module.exports=r,module.exports=exports.default;//# sourceMappingURL=rollup.cjs.map
|
package/dist/rollup.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{plugin as r}from"./chunk-
|
|
1
|
+
import{plugin as r}from"./chunk-YUBBVNLZ.js";import"./chunk-7BERUFQQ.js";import"./chunk-MROI2TT6.js";import"./chunk-OSLESBPI.js";import"./chunk-7QVYU63E.js";var o=r.rollup;export{o as default};//# sourceMappingURL=rollup.js.map
|
package/dist/rspack.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("./chunk-
|
|
1
|
+
"use strict";var e=require("./chunk-WQ3PTPJG.cjs");require("./chunk-UQ7VVNQE.cjs"),require("./chunk-PHIKG3MI.cjs"),require("./chunk-M2KOJHTB.cjs"),require("./chunk-PK6SKIKE.cjs");var r=e.plugin.rspack;module.exports=r,module.exports=exports.default;//# sourceMappingURL=rspack.cjs.map
|
package/dist/rspack.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{plugin as r}from"./chunk-
|
|
1
|
+
import{plugin as r}from"./chunk-YUBBVNLZ.js";import"./chunk-7BERUFQQ.js";import"./chunk-MROI2TT6.js";import"./chunk-OSLESBPI.js";import"./chunk-7QVYU63E.js";var o=r.rspack;export{o as default};//# sourceMappingURL=rspack.js.map
|
package/dist/vite.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("./chunk-
|
|
1
|
+
"use strict";var e=require("./chunk-WQ3PTPJG.cjs");require("./chunk-UQ7VVNQE.cjs"),require("./chunk-PHIKG3MI.cjs"),require("./chunk-M2KOJHTB.cjs"),require("./chunk-PK6SKIKE.cjs");var r=e.plugin.vite;module.exports=r,module.exports=exports.default;//# sourceMappingURL=vite.cjs.map
|
package/dist/vite.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{plugin as r}from"./chunk-
|
|
1
|
+
import{plugin as r}from"./chunk-YUBBVNLZ.js";import"./chunk-7BERUFQQ.js";import"./chunk-MROI2TT6.js";import"./chunk-OSLESBPI.js";import"./chunk-7QVYU63E.js";var t=r.vite;export{t as default};//# sourceMappingURL=vite.js.map
|
package/dist/webpack.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("./chunk-
|
|
1
|
+
"use strict";var e=require("./chunk-WQ3PTPJG.cjs");require("./chunk-UQ7VVNQE.cjs"),require("./chunk-PHIKG3MI.cjs"),require("./chunk-M2KOJHTB.cjs"),require("./chunk-PK6SKIKE.cjs");var r=e.plugin.webpack;module.exports=r,module.exports=exports.default;//# sourceMappingURL=webpack.cjs.map
|
package/dist/webpack.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{plugin as r}from"./chunk-
|
|
1
|
+
import{plugin as r}from"./chunk-YUBBVNLZ.js";import"./chunk-7BERUFQQ.js";import"./chunk-MROI2TT6.js";import"./chunk-OSLESBPI.js";import"./chunk-7QVYU63E.js";var o=r.webpack;export{o as default};//# sourceMappingURL=webpack.js.map
|
package/package.json
CHANGED
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shellicar/build-graphql",
|
|
3
|
+
"private": false,
|
|
4
|
+
"version": "1.0.1",
|
|
3
5
|
"type": "module",
|
|
4
|
-
"version": "0.1.1",
|
|
5
|
-
"description": "Build plugin that loads GraphQL files and makes them importable via a virtual typedefs module.",
|
|
6
6
|
"license": "MIT",
|
|
7
|
-
"
|
|
7
|
+
"author": "Stephen Hellicar",
|
|
8
|
+
"description": "Build plugin that loads GraphQL files and makes them importable via a virtual typedefs module.",
|
|
9
|
+
"keywords": [
|
|
10
|
+
"build",
|
|
11
|
+
"plugin",
|
|
12
|
+
"graphql",
|
|
13
|
+
"esbuild",
|
|
14
|
+
"vite"
|
|
15
|
+
],
|
|
8
16
|
"repository": {
|
|
9
17
|
"type": "git",
|
|
10
18
|
"url": "git+https://github.com/shellicar/build-graphql.git"
|
|
@@ -12,70 +20,169 @@
|
|
|
12
20
|
"bugs": {
|
|
13
21
|
"url": "https://github.com/shellicar/build-graphql/issues"
|
|
14
22
|
},
|
|
15
|
-
"
|
|
16
|
-
|
|
17
|
-
"
|
|
18
|
-
|
|
19
|
-
"vite",
|
|
20
|
-
"webpack",
|
|
21
|
-
"rollup",
|
|
22
|
-
"transform"
|
|
23
|
-
],
|
|
23
|
+
"homepage": "https://github.com/shellicar/build-graphql#readme",
|
|
24
|
+
"publishConfig": {
|
|
25
|
+
"access": "public"
|
|
26
|
+
},
|
|
24
27
|
"exports": {
|
|
25
28
|
".": {
|
|
26
|
-
"
|
|
27
|
-
|
|
29
|
+
"require": {
|
|
30
|
+
"types": "./dist/index.d.cts",
|
|
31
|
+
"default": "./dist/index.cjs"
|
|
32
|
+
},
|
|
33
|
+
"import": {
|
|
34
|
+
"types": "./dist/index.d.ts",
|
|
35
|
+
"default": "./dist/index.js"
|
|
36
|
+
}
|
|
28
37
|
},
|
|
29
38
|
"./astro": {
|
|
30
|
-
"
|
|
31
|
-
|
|
39
|
+
"require": {
|
|
40
|
+
"types": "./dist/astro.d.cts",
|
|
41
|
+
"default": "./dist/astro.cjs"
|
|
42
|
+
},
|
|
43
|
+
"import": {
|
|
44
|
+
"types": "./dist/astro.d.ts",
|
|
45
|
+
"default": "./dist/astro.js"
|
|
46
|
+
}
|
|
32
47
|
},
|
|
33
48
|
"./rspack": {
|
|
34
|
-
"
|
|
35
|
-
|
|
49
|
+
"require": {
|
|
50
|
+
"types": "./dist/rspack.d.cts",
|
|
51
|
+
"default": "./dist/rspack.cjs"
|
|
52
|
+
},
|
|
53
|
+
"import": {
|
|
54
|
+
"types": "./dist/rspack.d.ts",
|
|
55
|
+
"default": "./dist/rspack.js"
|
|
56
|
+
}
|
|
36
57
|
},
|
|
37
58
|
"./vite": {
|
|
38
|
-
"
|
|
39
|
-
|
|
59
|
+
"require": {
|
|
60
|
+
"types": "./dist/vite.d.cts",
|
|
61
|
+
"default": "./dist/vite.cjs"
|
|
62
|
+
},
|
|
63
|
+
"import": {
|
|
64
|
+
"types": "./dist/vite.d.ts",
|
|
65
|
+
"default": "./dist/vite.js"
|
|
66
|
+
}
|
|
40
67
|
},
|
|
41
68
|
"./webpack": {
|
|
42
|
-
"
|
|
43
|
-
|
|
69
|
+
"require": {
|
|
70
|
+
"types": "./dist/webpack.d.cts",
|
|
71
|
+
"default": "./dist/webpack.cjs"
|
|
72
|
+
},
|
|
73
|
+
"import": {
|
|
74
|
+
"types": "./dist/webpack.d.ts",
|
|
75
|
+
"default": "./dist/webpack.js"
|
|
76
|
+
}
|
|
44
77
|
},
|
|
45
78
|
"./rollup": {
|
|
46
|
-
"
|
|
47
|
-
|
|
79
|
+
"require": {
|
|
80
|
+
"types": "./dist/rollup.d.cts",
|
|
81
|
+
"default": "./dist/rollup.cjs"
|
|
82
|
+
},
|
|
83
|
+
"import": {
|
|
84
|
+
"types": "./dist/rollup.d.ts",
|
|
85
|
+
"default": "./dist/rollup.js"
|
|
86
|
+
}
|
|
48
87
|
},
|
|
49
88
|
"./esbuild": {
|
|
50
|
-
"
|
|
51
|
-
|
|
89
|
+
"require": {
|
|
90
|
+
"types": "./dist/esbuild.d.cts",
|
|
91
|
+
"default": "./dist/esbuild.cjs"
|
|
92
|
+
},
|
|
93
|
+
"import": {
|
|
94
|
+
"types": "./dist/esbuild.d.ts",
|
|
95
|
+
"default": "./dist/esbuild.js"
|
|
96
|
+
}
|
|
52
97
|
},
|
|
53
98
|
"./nuxt": {
|
|
54
|
-
"
|
|
55
|
-
|
|
99
|
+
"require": {
|
|
100
|
+
"types": "./dist/nuxt.d.cts",
|
|
101
|
+
"default": "./dist/nuxt.cjs"
|
|
102
|
+
},
|
|
103
|
+
"import": {
|
|
104
|
+
"types": "./dist/nuxt.d.ts",
|
|
105
|
+
"default": "./dist/nuxt.js"
|
|
106
|
+
}
|
|
56
107
|
},
|
|
57
108
|
"./farm": {
|
|
58
|
-
"
|
|
59
|
-
|
|
109
|
+
"require": {
|
|
110
|
+
"types": "./dist/farm.d.cts",
|
|
111
|
+
"default": "./dist/farm.cjs"
|
|
112
|
+
},
|
|
113
|
+
"import": {
|
|
114
|
+
"types": "./dist/farm.d.ts",
|
|
115
|
+
"default": "./dist/farm.js"
|
|
116
|
+
}
|
|
60
117
|
},
|
|
61
118
|
"./types": {
|
|
62
|
-
"
|
|
63
|
-
|
|
119
|
+
"require": {
|
|
120
|
+
"types": "./dist/core/types.d.cts",
|
|
121
|
+
"default": "./dist/core/types.cjs"
|
|
122
|
+
},
|
|
123
|
+
"import": {
|
|
124
|
+
"types": "./dist/core/types.d.ts",
|
|
125
|
+
"default": "./dist/core/types.js"
|
|
126
|
+
}
|
|
64
127
|
},
|
|
65
128
|
"./typedefs": {
|
|
66
|
-
"
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
129
|
+
"require": {
|
|
130
|
+
"types": "./dist/core/typedefs.d.cts",
|
|
131
|
+
"default": "./dist/core/typedefs.cjs"
|
|
132
|
+
},
|
|
133
|
+
"import": {
|
|
134
|
+
"types": "./dist/core/typedefs.d.ts",
|
|
135
|
+
"default": "./dist/core/typedefs.js"
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
"./*": {
|
|
139
|
+
"require": {
|
|
140
|
+
"types": "./dist/*.d.cts",
|
|
141
|
+
"default": "./dist/*.cjs"
|
|
142
|
+
},
|
|
143
|
+
"import": {
|
|
144
|
+
"types": "./dist/*.d.ts",
|
|
145
|
+
"default": "./dist/*.js"
|
|
146
|
+
}
|
|
147
|
+
}
|
|
70
148
|
},
|
|
71
149
|
"main": "dist/index.cjs",
|
|
72
150
|
"module": "dist/index.js",
|
|
73
151
|
"types": "dist/index.d.ts",
|
|
74
152
|
"typesVersions": {
|
|
75
153
|
"*": {
|
|
154
|
+
"astro": [
|
|
155
|
+
"./dist/astro.d.ts"
|
|
156
|
+
],
|
|
157
|
+
"rspack": [
|
|
158
|
+
"./dist/rspack.d.ts"
|
|
159
|
+
],
|
|
160
|
+
"vite": [
|
|
161
|
+
"./dist/vite.d.ts"
|
|
162
|
+
],
|
|
163
|
+
"webpack": [
|
|
164
|
+
"./dist/webpack.d.ts"
|
|
165
|
+
],
|
|
166
|
+
"rollup": [
|
|
167
|
+
"./dist/rollup.d.ts"
|
|
168
|
+
],
|
|
169
|
+
"esbuild": [
|
|
170
|
+
"./dist/esbuild.d.ts"
|
|
171
|
+
],
|
|
172
|
+
"nuxt": [
|
|
173
|
+
"./dist/nuxt.d.ts"
|
|
174
|
+
],
|
|
175
|
+
"farm": [
|
|
176
|
+
"./dist/farm.d.ts"
|
|
177
|
+
],
|
|
178
|
+
"types": [
|
|
179
|
+
"./dist/core/types.d.ts"
|
|
180
|
+
],
|
|
181
|
+
"typedefs": [
|
|
182
|
+
"./dist/core/typedefs.d.ts"
|
|
183
|
+
],
|
|
76
184
|
"*": [
|
|
77
|
-
"./dist/*"
|
|
78
|
-
"./*"
|
|
185
|
+
"./dist/*"
|
|
79
186
|
]
|
|
80
187
|
}
|
|
81
188
|
},
|
|
@@ -83,9 +190,6 @@
|
|
|
83
190
|
"dist",
|
|
84
191
|
"*.md"
|
|
85
192
|
],
|
|
86
|
-
"publishConfig": {
|
|
87
|
-
"access": "public"
|
|
88
|
-
},
|
|
89
193
|
"peerDependencies": {
|
|
90
194
|
"@farmfe/core": ">=1",
|
|
91
195
|
"@nuxt/kit": "^3",
|
|
@@ -120,8 +224,8 @@
|
|
|
120
224
|
},
|
|
121
225
|
"devDependencies": {
|
|
122
226
|
"@luckycatfactory/esbuild-graphql-loader": "^3.8.1",
|
|
123
|
-
"@nuxt/kit": "^3.15.
|
|
124
|
-
"@nuxt/schema": "^3.15.
|
|
227
|
+
"@nuxt/kit": "^3.15.1",
|
|
228
|
+
"@nuxt/schema": "^3.15.1",
|
|
125
229
|
"@tsconfig/node20": "^20.1.4",
|
|
126
230
|
"@types/node": "^22.10.5",
|
|
127
231
|
"bumpp": "^9.9.2",
|
|
@@ -129,7 +233,7 @@
|
|
|
129
233
|
"esno": "^4.8.0",
|
|
130
234
|
"npm-check-updates": "^17.1.13",
|
|
131
235
|
"npm-run-all2": "^7.0.2",
|
|
132
|
-
"rollup": "^4.
|
|
236
|
+
"rollup": "^4.30.0",
|
|
133
237
|
"terser": "^5.37.0",
|
|
134
238
|
"tsup": "^8.3.5",
|
|
135
239
|
"vite": "^6.0.7",
|
|
@@ -144,6 +248,7 @@
|
|
|
144
248
|
},
|
|
145
249
|
"scripts": {
|
|
146
250
|
"build": "tsup",
|
|
147
|
-
"dev": "tsup --watch
|
|
251
|
+
"dev": "tsup --watch",
|
|
252
|
+
"type-check": "tsc -p tsconfig.check.json"
|
|
148
253
|
}
|
|
149
254
|
}
|
package/CHANGELOG.md
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
## [0.1.1] - 2025-01-05
|
|
4
|
-
|
|
5
|
-
### Fixed
|
|
6
|
-
|
|
7
|
-
Fix missing README
|
|
8
|
-
|
|
9
|
-
## [0.1.0] - 2025-01-05
|
|
10
|
-
|
|
11
|
-
Initial release.
|
|
12
|
-
|
|
13
|
-
[0.1.1]: https://github.com/shellicar/build-graphql/releases/tag/0.1.1
|
|
14
|
-
[0.1.0]: https://github.com/shellicar/build-graphql/releases/tag/0.1.0
|
package/dist/chunk-OLAXA3NW.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";exports.defaults={globPattern:"**/*.graphql",globIgnore:"**/node_modules/**",ignoreErrors:!1,debug:!1,typedefsPath:"@shellicar/build-graphql/dist/core/typedefs\\.c?js$"};//# sourceMappingURL=chunk-OLAXA3NW.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/core/defaults.ts"],"names":[],"mappings":";AAEO,IAAM,QAAW,GAAA;AAAA,EACtB,WAAa,EAAA,cAAA;AAAA,EACb,UAAY,EAAA,oBAAA;AAAA,EACZ,YAAc,EAAA,KAAA;AAAA,EACd,KAAO,EAAA,KAAA;AAAA,EACP,YAAc,EAAA;AAChB","file":"chunk-OLAXA3NW.cjs","sourcesContent":["import type { Options } from './types';\n\nexport const defaults = {\n globPattern: '**/*.graphql',\n globIgnore: '**/node_modules/**',\n ignoreErrors: false,\n debug: false,\n typedefsPath: '@shellicar/build-graphql/dist/core/typedefs\\\\.c?js$',\n} as const satisfies Options;\n"]}
|
package/dist/chunk-Q6776UY5.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var e={globPattern:"**/*.graphql",globIgnore:"**/node_modules/**",ignoreErrors:!1,debug:!1,typedefsPath:"@shellicar/build-graphql/dist/core/typedefs\\.c?js$"};export{e as defaults};//# sourceMappingURL=chunk-Q6776UY5.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/core/defaults.ts"],"names":[],"mappings":";AAEO,IAAM,QAAW,GAAA;AAAA,EACtB,WAAa,EAAA,cAAA;AAAA,EACb,UAAY,EAAA,oBAAA;AAAA,EACZ,YAAc,EAAA,KAAA;AAAA,EACd,KAAO,EAAA,KAAA;AAAA,EACP,YAAc,EAAA;AAChB","file":"chunk-Q6776UY5.js","sourcesContent":["import type { Options } from './types';\n\nexport const defaults = {\n globPattern: '**/*.graphql',\n globIgnore: '**/node_modules/**',\n ignoreErrors: false,\n debug: false,\n typedefsPath: '@shellicar/build-graphql/dist/core/typedefs\\\\.c?js$',\n} as const satisfies Options;\n"]}
|
package/dist/chunk-QBNFT4HT.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{defaults as e}from"./chunk-Q6776UY5.js";import{__name as t}from"./chunk-7QVYU63E.js";import r from"node:path";import n from"fs";import o from"graphql-tag";import i from"readline";import a from"path";import{glob as l}from"glob";import{createUnplugin as s}from"unplugin";var p=t(((e,t)=>{const r=t?t(e):e;return JSON.stringify(r,((e,t)=>void 0===t?"__undefined":t)).replace(/"__undefined"/g,"undefined")}),"generateDocumentNodeString"),d=t(((e,r)=>{const n=new Set,o=[],i=t((e=>{n.has(e)||(n.add(e),e.imports.forEach((e=>{const t=r[e.absolutePath];i(t)})),o.unshift(e))}),"visitFile");return e.forEach(i),o}),"topologicallySortParsedFiles"),c=t((e=>new Promise((r=>{const o=i.createInterface({input:n.createReadStream(e)});let l="";const s=[];let p=!1;const d=t(((t,r)=>{const n=r.replace(t,""),o=n.replace(/"|'/g,""),i=a.join(a.dirname(e),o);s.push({absolutePath:i,relativePath:n})}),"parseImportAndCapture");o.on("line",(e=>{e.startsWith("#import ")?d("#import ",e):e.startsWith("# import ")?d("# import ",e):p?l+=e+"\n":"#"!==e[0]&&""!==e&&(p=!0,l+=e+"\n")})),o.on("close",(()=>{r({body:l.trim(),filePath:e,imports:s})}))}))),"parseGraphQLFile"),m=t((e=>{const r={},n=[],o=new Set,i=t((e=>r[e]?Promise.resolve(null):new Promise((t=>{c(e).then((e=>{r[e.filePath]=e,e.imports.forEach((e=>{o.has(e.absolutePath)||(o.add(e.absolutePath),n.push(i(e.absolutePath)))}));const a=n.shift();return a?a.then(t):t(null)}))}))),"visitAndParse");return i(e).then((()=>d(Object.values(r),r).reduce(((e,t)=>t.body+"\n\n"+e),"")))}),"generateGraphQLString"),u=t(((e,t,r)=>{const n={kind:"Document",definitions:[e,...t]};return p(n,r)}),"generateDocumentNodeStringForOperationDefinition"),f=t((e=>t(((e,t)=>(e.forEach((e=>{"FragmentDefinition"===e.kind&&(t[e.name.value]=e)})),t)),"accumulateAllFragments")(e.definitions,{})),"collectAllFragmentDefinitions"),h=t(((e,r)=>{const n=[],o=t((e=>{if("FragmentSpread"===e.kind){const t=r[e.name.value],o=h(t,r);n.push(...o,e.name.value)}}),"handleSelectionNode");return"OperationDefinition"===e.kind?e.selectionSet.selections.forEach((e=>{var t;"Field"===e.kind&&(null==(t=e.selectionSet)||t.selections.forEach(o))})):e.selectionSet.selections.forEach(o),n}),"collectAllFragmentReferences"),g=t(((e,t)=>{const r=o(e),n=p(r,t),i=f(r),a=r.definitions.reduce(((e,r)=>{if("OperationDefinition"===r.kind&&r.name&&r.name.value){const n=r.name.value,o=h(r,i).map((e=>{const t=i[e];if(!t)throw new Error(`Expected to find fragment definition for ${e}`);return t})),a=u(r,o,t);e.push(`export const ${n} = ${a};`)}return e}),[`const documentNode = ${n};`]);return a.push("export default documentNode;"),a.join("\n")}),"generateContentsFromGraphqlString"),b=t((async e=>(await l(e.globPattern,{ignore:e.globIgnore})).map(((e,t)=>({path:r.join(process.cwd(),e).replace(/\\/g,"/"),name:`gql_${t}`})))),"findGraphQLFiles"),v=t((e=>[...e.map((e=>`import ${e.name} from '${e.path}';`)),`export default ${`[${e.map((e=>e.name)).join(", ")}]`};`].join("\n")),"generateTypedefsFile"),w=s(t(((n,o)=>{const i={...e,...n},a=t(((e,...t)=>{i.debug&&console.log("[graphql]:",e,...t)}),"log");null==i.rootDir&&(i.rootDir=process.cwd());const s=i.rootDir;let p=[];const d=[];let c=!1;a({options:i});const u=new RegExp(i.typedefsPath),f=t((e=>"vite"===o.framework?u.test(e):"@shellicar/build-graphql/typedefs"===e),"matchTypedefs"),h=t((e=>e.endsWith(".graphql")),"matchGraphql");return{name:"graphql",buildStart:t((async()=>{a("Build start"),p=await l(i.globPattern,{ignore:i.globIgnore})}),"buildStart"),resolveId:e=>f(e)?e:h(e)?r.resolve(s,e):void 0,loadInclude:e=>h(e)||f(e),load:t((async e=>{if(f(e)){c=!0;const e=await b(i),t=v(e);return a(`Typedefs: \`${t}\``),{code:t,map:null}}if(h(e)){const t=r.isAbsolute(e)?e:r.resolve(s,e),n=await m(t);return d.push(e),{code:g(n,i.mapDocumentNode),map:null}}}),"load"),buildEnd:t((()=>{if(a("Build end",{graphqlMatched:p,graphqlImports:d,importedTypedefs:c}),!i.ignoreErrors){if(0===p.length)throw new Error(`No GraphQL files found for the pattern: ${i.globPattern}`);if(!c)throw new Error("Typedefs not imported. Make sure to import from @shellicar/build-graphql/typedefs")}}),"buildEnd")}}),"graphqlPluginFactory"));export{w as plugin};//# sourceMappingURL=chunk-QBNFT4HT.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../node_modules/.pnpm/@luckycatfactory+esbuild-graphql-loader@3.8.1_esbuild@0.24.2_graphql-tag@2.12.6_graphql@16.10.0__graphql@16.10.0/node_modules/@luckycatfactory/esbuild-graphql-loader/lib/index.mjs","../src/core/index.ts"],"names":[],"mappings":"uRAKA,IAAI,0BAAA,mBAA8B,MAAA,CAAA,CAAA,eAAA,EAAiB,eAAoB,KAAA;AACrE,EAAA,MAAM,iBAAoB,GAAA,eAAA,GAAkB,eAAgB,CAAA,eAAe,CAAI,GAAA,eAAA;AAC/E,EAAA,OAAO,IAAK,CAAA,SAAA,CAAU,iBAAmB,EAAA,CAAC,GAAK,EAAA,KAAA,KAAU,KAAU,KAAA,KAAA,CAAA,GAAS,aAAgB,GAAA,KAAK,CAAE,CAAA,OAAA,CAAQ,kBAAkB,WAAW,CAAA;AAC1I,CAHiC,EAAA,4BAAA,CAAA;AAIjC,IAAI,4BAAA,mBAAgC,MAAA,CAAA,CAAA,WAAA,EAAa,KAAU,KAAA;AACzD,EAAM,MAAA,YAAA,uBAAmB,GAAI,EAAA;AAC7B,EAAA,MAAM,SAAS,EAAC;AAChB,EAAM,MAAA,SAAA,2BAAa,IAAS,KAAA;AAC1B,IAAI,IAAA,YAAA,CAAa,IAAI,IAAI,CAAA;AACvB,MAAA;AACF,IAAA,YAAA,CAAa,IAAI,IAAI,CAAA;AACrB,IAAK,IAAA,CAAA,OAAA,CAAQ,OAAQ,CAAA,CAAC,eAAoB,KAAA;AACxC,MAAM,MAAA,YAAA,GAAe,KAAM,CAAA,eAAA,CAAgB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Aa,EAAA;AAAA,QACf,cAAA;AAAA,QACA,cAAA;AAAA,QACA;AAAA,OACD,CAAA;AACD,MAAI,IAAA,CAAC,QAAQ,YAAc,EAAA;AACzB,QAAI,IAAA,cAAA,CAAe,WAAW,CAAG,EAAA;AAC/B,UAAA,MAAM,IAAI,KAAA,CAAM,CAA2C,wCAAA,EAAA,OAAA,CAAQ,WAAW,CAAE,CAAA,CAAA;AAAA;AAElF,QAAA,IAAI,CAAC,gBAAkB,EAAA;AACrB,UAAM,MAAA,IAAI,MAAM,mFAAmF,CAAA;AAAA;AACrG;AACF,KAbQ,EAAA,UAAA;AAAA,GAeZ;AACF,CArFuD,EAAA,sBAAA,CAAA;AAsF1C,IAAA,MAAA,GAAS,eAAe,oBAAoB","file":"chunk-QBNFT4HT.js","sourcesContent":["// src/index.ts\nimport fs2 from \"fs\";\nimport gql from \"graphql-tag\";\nimport readline2 from \"readline\";\nimport path2 from \"path\";\nvar generateDocumentNodeString = (graphqlDocument, mapDocumentNode) => {\n const documentNodeToUse = mapDocumentNode ? mapDocumentNode(graphqlDocument) : graphqlDocument;\n return JSON.stringify(documentNodeToUse, (key, value) => value === void 0 ? \"__undefined\" : value).replace(/\"__undefined\"/g, \"undefined\");\n};\nvar topologicallySortParsedFiles = (parsedFiles, cache) => {\n const visitedFiles = new Set();\n const sorted = [];\n const visitFile = (file) => {\n if (visitedFiles.has(file))\n return;\n visitedFiles.add(file);\n file.imports.forEach((importFileEntry) => {\n const importedFile = cache[importFileEntry.absolutePath];\n visitFile(importedFile);\n });\n sorted.unshift(file);\n };\n parsedFiles.forEach(visitFile);\n return sorted;\n};\nvar parseGraphQLFile = (filePath) => new Promise((resolve) => {\n const readInterface = readline2.createInterface({\n input: fs2.createReadStream(filePath)\n });\n let body = \"\";\n const imports = [];\n let hasExhaustedImports = false;\n const parseImportAndCapture = (importCommentPrefix, line) => {\n const relativePath = line.replace(importCommentPrefix, \"\");\n const relativePathWithoutQuotations = relativePath.replace(/\"|'/g, \"\");\n const absolutePath = path2.join(path2.dirname(filePath), relativePathWithoutQuotations);\n imports.push({\n absolutePath,\n relativePath\n });\n };\n readInterface.on(\"line\", (line) => {\n if (line.startsWith(\"#import \")) {\n parseImportAndCapture(\"#import \", line);\n } else if (line.startsWith(\"# import \")) {\n parseImportAndCapture(\"# import \", line);\n } else if (hasExhaustedImports) {\n body += line + \"\\n\";\n } else if (line[0] !== \"#\" && line !== \"\") {\n hasExhaustedImports = true;\n body += line + \"\\n\";\n }\n });\n readInterface.on(\"close\", () => {\n resolve({body: body.trim(), filePath, imports});\n });\n});\nvar generateGraphQLString = (entryPointPath) => {\n const cache = {};\n const parsePromises = [];\n const seenImportPaths = new Set();\n const visitAndParse = (filePath) => {\n if (cache[filePath])\n return Promise.resolve(null);\n return new Promise((resolve) => {\n parseGraphQLFile(filePath).then((parsedFile) => {\n cache[parsedFile.filePath] = parsedFile;\n parsedFile.imports.forEach((importEntry) => {\n if (!seenImportPaths.has(importEntry.absolutePath)) {\n seenImportPaths.add(importEntry.absolutePath);\n parsePromises.push(visitAndParse(importEntry.absolutePath));\n }\n });\n const nextPromise = parsePromises.shift();\n if (nextPromise) {\n return nextPromise.then(resolve);\n }\n return resolve(null);\n });\n });\n };\n return visitAndParse(entryPointPath).then(() => {\n const files = topologicallySortParsedFiles(Object.values(cache), cache);\n const graphqlString = files.reduce((accumulator, file) => {\n return file.body + \"\\n\\n\" + accumulator;\n }, \"\");\n return graphqlString;\n });\n};\nvar generateDocumentNodeStringForOperationDefinition = (operationDefinition, fragments, mapDocumentNode) => {\n const operationDocument = {\n kind: \"Document\",\n definitions: [operationDefinition, ...fragments]\n };\n return generateDocumentNodeString(operationDocument, mapDocumentNode);\n};\nvar collectAllFragmentDefinitions = (documentNode) => {\n const accumulateAllFragments = (nodes, accumulator) => {\n nodes.forEach((node) => {\n if (node.kind === \"FragmentDefinition\") {\n accumulator[node.name.value] = node;\n }\n });\n return accumulator;\n };\n return accumulateAllFragments(documentNode.definitions, {});\n};\nvar collectAllFragmentReferences = (node, allFragments) => {\n const references = [];\n const handleSelectionNode = (selection) => {\n if (selection.kind === \"FragmentSpread\") {\n const fragment = allFragments[selection.name.value];\n const innerFragmentReferences = collectAllFragmentReferences(fragment, allFragments);\n references.push(...innerFragmentReferences, selection.name.value);\n }\n };\n if (node.kind === \"OperationDefinition\") {\n node.selectionSet.selections.forEach((selection) => {\n var _a;\n if (selection.kind === \"Field\") {\n (_a = selection.selectionSet) == null ? void 0 : _a.selections.forEach(handleSelectionNode);\n }\n });\n } else {\n node.selectionSet.selections.forEach(handleSelectionNode);\n }\n return references;\n};\nvar generateContentsFromGraphqlString = (graphqlString, mapDocumentNode) => {\n const graphqlDocument = gql(graphqlString);\n const documentNodeAsString = generateDocumentNodeString(graphqlDocument, mapDocumentNode);\n const allFragments = collectAllFragmentDefinitions(graphqlDocument);\n const lines = graphqlDocument.definitions.reduce((accumulator, definition) => {\n if (definition.kind === \"OperationDefinition\" && definition.name && definition.name.value) {\n const name = definition.name.value;\n const fragmentsForOperation = collectAllFragmentReferences(definition, allFragments);\n const fragments = fragmentsForOperation.map((fragmentForOperation) => {\n const fragment = allFragments[fragmentForOperation];\n if (!fragment) {\n throw new Error(`Expected to find fragment definition for ${fragmentForOperation}`);\n }\n return fragment;\n });\n const operationDocumentString = generateDocumentNodeStringForOperationDefinition(definition, fragments, mapDocumentNode);\n accumulator.push(`export const ${name} = ${operationDocumentString};`);\n }\n return accumulator;\n }, [`const documentNode = ${documentNodeAsString};`]);\n lines.push(`export default documentNode;`);\n return lines.join(\"\\n\");\n};\nvar graphqlLoaderPlugin = (options = {}) => ({\n name: \"graphql-loader\",\n setup(build) {\n build.onLoad({filter: options.filterRegex || /\\.graphql$|\\.gql$/}, (args) => generateGraphQLString(args.path).then((graphqlString) => ({\n contents: generateContentsFromGraphqlString(graphqlString, options.mapDocumentNode)\n })));\n }\n});\nvar src_default = graphqlLoaderPlugin;\nexport {\n src_default as default,\n generateContentsFromGraphqlString,\n generateGraphQLString\n};\n","import path from 'node:path';\nimport { generateContentsFromGraphqlString, generateGraphQLString } from '@luckycatfactory/esbuild-graphql-loader';\nimport { glob } from 'glob';\nimport type { UnpluginFactory } from 'unplugin';\nimport { createUnplugin } from 'unplugin';\nimport { defaults } from './defaults';\nimport type { Options } from './types';\n\ntype GraphqlFile = {\n path: string;\n name: string;\n};\n\nconst findGraphQLFiles = async (options: { globPattern: string; globIgnore: string }): Promise<GraphqlFile[]> => {\n const files = await glob(options.globPattern, { ignore: options.globIgnore });\n return files.map((file, index) => ({\n path: path.join(process.cwd(), file).replace(/\\\\/g, '/'),\n name: `gql_${index}`,\n }));\n};\n\nconst generateTypedefsFile = (files: GraphqlFile[]) => {\n const importStatements = files.map((f) => `import ${f.name} from '${f.path}';`);\n\n const documentsArray = `[${files.map((f) => f.name).join(', ')}]`;\n\n const code = [...importStatements, `export default ${documentsArray};`];\n return code.join('\\n');\n};\n\nconst graphqlPluginFactory: UnpluginFactory<Options> = (inputOptions, meta) => {\n const options = {\n ...defaults,\n ...inputOptions,\n };\n const log = (message: any, ...args: any) => {\n if (options.debug) {\n console.log('[graphql]:', message, ...args);\n }\n };\n\n if (options.rootDir == null) {\n options.rootDir = process.cwd();\n }\n const rootDir = options.rootDir;\n let graphqlMatched: string[] = [];\n const graphqlImports: string[] = [];\n let importedTypedefs = false;\n log({ options });\n\n const MODULE_ID = '@shellicar/build-graphql/typedefs';\n\n const typedefsPattern = new RegExp(options.typedefsPath);\n\n const matchTypedefs = (id: string) => {\n if (meta.framework === 'vite') {\n return typedefsPattern.test(id);\n }\n return id === MODULE_ID;\n };\n const matchGraphql = (id: string) => {\n return id.endsWith('.graphql');\n };\n\n return {\n name: 'graphql',\n buildStart: async () => {\n log('Build start');\n graphqlMatched = await glob(options.globPattern, { ignore: options.globIgnore });\n },\n resolveId(id) {\n if (matchTypedefs(id)) {\n return id;\n }\n if (matchGraphql(id)) {\n return path.resolve(rootDir, id);\n }\n },\n loadInclude(id) {\n return matchGraphql(id) || matchTypedefs(id);\n },\n load: async (id) => {\n if (matchTypedefs(id)) {\n importedTypedefs = true;\n const files = await findGraphQLFiles(options);\n const code = generateTypedefsFile(files);\n log(`Typedefs: \\`${code}\\``);\n return { code, map: null };\n }\n if (matchGraphql(id)) {\n const absolutePath = path.isAbsolute(id) ? id : path.resolve(rootDir, id);\n const graphqlString = await generateGraphQLString(absolutePath);\n graphqlImports.push(id);\n return {\n code: generateContentsFromGraphqlString(graphqlString, options.mapDocumentNode),\n map: null,\n };\n }\n },\n buildEnd: () => {\n log('Build end', {\n graphqlMatched,\n graphqlImports,\n importedTypedefs,\n });\n if (!options.ignoreErrors) {\n if (graphqlMatched.length === 0) {\n throw new Error(`No GraphQL files found for the pattern: ${options.globPattern}`);\n }\n if (!importedTypedefs) {\n throw new Error('Typedefs not imported. Make sure to import from @shellicar/build-graphql/typedefs');\n }\n }\n },\n };\n};\nexport const plugin = createUnplugin(graphqlPluginFactory);\n"]}
|
package/dist/chunk-VLAENKR2.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";var e=require("./chunk-OLAXA3NW.cjs"),t=require("./chunk-PK6SKIKE.cjs"),n=require("path"),r=require("fs"),a=require("graphql-tag"),o=require("readline"),i=require("glob"),l=require("unplugin");function s(e){return e&&e.__esModule?e:{default:e}}var u=s(n),d=s(r),c=s(a),p=s(o),m=t.__name(((e,t)=>{const n=t?t(e):e;return JSON.stringify(n,((e,t)=>void 0===t?"__undefined":t)).replace(/"__undefined"/g,"undefined")}),"generateDocumentNodeString"),f=t.__name(((e,n)=>{const r=new Set,a=[],o=t.__name((e=>{r.has(e)||(r.add(e),e.imports.forEach((e=>{const t=n[e.absolutePath];o(t)})),a.unshift(e))}),"visitFile");return e.forEach(o),a}),"topologicallySortParsedFiles"),h=t.__name((e=>new Promise((n=>{const r=p.default.createInterface({input:d.default.createReadStream(e)});let a="";const o=[];let i=!1;const l=t.__name(((t,n)=>{const r=n.replace(t,""),a=r.replace(/"|'/g,""),i=u.default.join(u.default.dirname(e),a);o.push({absolutePath:i,relativePath:r})}),"parseImportAndCapture");r.on("line",(e=>{e.startsWith("#import ")?l("#import ",e):e.startsWith("# import ")?l("# import ",e):i?a+=e+"\n":"#"!==e[0]&&""!==e&&(i=!0,a+=e+"\n")})),r.on("close",(()=>{n({body:a.trim(),filePath:e,imports:o})}))}))),"parseGraphQLFile"),g=t.__name((e=>{const n={},r=[],a=new Set,o=t.__name((e=>n[e]?Promise.resolve(null):new Promise((t=>{h(e).then((e=>{n[e.filePath]=e,e.imports.forEach((e=>{a.has(e.absolutePath)||(a.add(e.absolutePath),r.push(o(e.absolutePath)))}));const i=r.shift();return i?i.then(t):t(null)}))}))),"visitAndParse");return o(e).then((()=>f(Object.values(n),n).reduce(((e,t)=>t.body+"\n\n"+e),"")))}),"generateGraphQLString"),_=t.__name(((e,t,n)=>{const r={kind:"Document",definitions:[e,...t]};return m(r,n)}),"generateDocumentNodeStringForOperationDefinition"),b=t.__name((e=>t.__name(((e,t)=>(e.forEach((e=>{"FragmentDefinition"===e.kind&&(t[e.name.value]=e)})),t)),"accumulateAllFragments")(e.definitions,{})),"collectAllFragmentDefinitions"),q=t.__name(((e,n)=>{const r=[],a=t.__name((e=>{if("FragmentSpread"===e.kind){const t=n[e.name.value],a=q(t,n);r.push(...a,e.name.value)}}),"handleSelectionNode");return"OperationDefinition"===e.kind?e.selectionSet.selections.forEach((e=>{var t;"Field"===e.kind&&(null==(t=e.selectionSet)||t.selections.forEach(a))})):e.selectionSet.selections.forEach(a),r}),"collectAllFragmentReferences"),v=t.__name(((e,t)=>{const n=c.default(e),r=m(n,t),a=b(n),o=n.definitions.reduce(((e,n)=>{if("OperationDefinition"===n.kind&&n.name&&n.name.value){const r=n.name.value,o=q(n,a).map((e=>{const t=a[e];if(!t)throw new Error(`Expected to find fragment definition for ${e}`);return t})),i=_(n,o,t);e.push(`export const ${r} = ${i};`)}return e}),[`const documentNode = ${r};`]);return o.push("export default documentNode;"),o.join("\n")}),"generateContentsFromGraphqlString"),P=t.__name((async e=>(await i.glob(e.globPattern,{ignore:e.globIgnore})).map(((e,t)=>({path:u.default.join(process.cwd(),e).replace(/\\/g,"/"),name:`gql_${t}`})))),"findGraphQLFiles"),w=t.__name((e=>[...e.map((e=>`import ${e.name} from '${e.path}';`)),`export default ${`[${e.map((e=>e.name)).join(", ")}]`};`].join("\n")),"generateTypedefsFile"),S=t.__name(((n,r)=>{const a={...e.defaults,...n},o=t.__name(((e,...t)=>{a.debug&&console.log("[graphql]:",e,...t)}),"log");null==a.rootDir&&(a.rootDir=process.cwd());const l=a.rootDir;let s=[];const d=[];let c=!1;o({options:a});const p=new RegExp(a.typedefsPath),m=t.__name((e=>"vite"===r.framework?p.test(e):"@shellicar/build-graphql/typedefs"===e),"matchTypedefs"),f=t.__name((e=>e.endsWith(".graphql")),"matchGraphql");return{name:"graphql",buildStart:t.__name((async()=>{o("Build start"),s=await i.glob(a.globPattern,{ignore:a.globIgnore})}),"buildStart"),resolveId:e=>m(e)?e:f(e)?u.default.resolve(l,e):void 0,loadInclude:e=>f(e)||m(e),load:t.__name((async e=>{if(m(e)){c=!0;const e=await P(a),t=w(e);return o(`Typedefs: \`${t}\``),{code:t,map:null}}if(f(e)){const t=u.default.isAbsolute(e)?e:u.default.resolve(l,e),n=await g(t);return d.push(e),{code:v(n,a.mapDocumentNode),map:null}}}),"load"),buildEnd:t.__name((()=>{if(o("Build end",{graphqlMatched:s,graphqlImports:d,importedTypedefs:c}),!a.ignoreErrors){if(0===s.length)throw new Error(`No GraphQL files found for the pattern: ${a.globPattern}`);if(!c)throw new Error("Typedefs not imported. Make sure to import from @shellicar/build-graphql/typedefs")}}),"buildEnd")}}),"graphqlPluginFactory"),y=l.createUnplugin(S);exports.plugin=y;//# sourceMappingURL=chunk-VLAENKR2.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../node_modules/.pnpm/@luckycatfactory+esbuild-graphql-loader@3.8.1_esbuild@0.24.2_graphql-tag@2.12.6_graphql@16.10.0__graphql@16.10.0/node_modules/@luckycatfactory/esbuild-graphql-loader/lib/index.mjs","../src/core/index.ts"],"names":["__name","readline2","fs2","path2","gql","glob","path","defaults","createUnplugin"],"mappings":"kiBAKA,IAAI,0BAAA,mBAA8BA,wBAAA,CAAA,CAAA,eAAA,EAAiB,eAAoB,KAAA;AACrE,EAAA,MAAM,iBAAoB,GAAA,eAAA,GAAkB,eAAgB,CAAA,eAAe,CAAI,GAAA,eAAA;AAC/E,EAAA,OAAO,IAAK,CAAA,SAAA,CAAU,iBAAmB,EAAA,CAAC,GAAK,EAAA,KAAA,KAAU,KAAU,KAAA,KAAA,CAAA,GAAS,aAAgB,GAAA,KAAK,CAAE,CAAA,OAAA,CAAQ,kBAAkB,WAAW,CAAA;AAC1I,CAHiC,EAAA,4BAAA,CAAA;AAIjC,IAAI,4BAAA,mBAAgCA,wBAAA,CAAA,CAAA,WAAA,EAAa,KAAU,KAAA;AACzD,EAAM,MAAA,YAAA,uBAAmB,GAAI,EAAA;AAC7B,EAAA,MAAM,SAAS,EAAC;AAChB,EAAM,MAAA,SAAA,6CAAa,IAAS,KAAA;AAC1B,IAAI,IAAA,YAAA,CAAa,IAAI,IAAI,CAAA;AACvB,MAAA;AACF,IAAA,YAAA,CAAa,IAAI,IAAI,CAAA;AACrB,IAAK,IAAA,CAAA,OAAA,CAAQ,OAAQ,CAAA,CAAC,eAAoB,KAAA;AACxC,MAAM,MAAA,YAAA,GAAe,KAAM,CAAA,eAAA,CAAgB,YAAY,CAAA;AACvD,MAAA,SAAA,CAAU,YAAY,CAAA;AAAA,KACvB,CAAA;AACD,IAAA,MAAA,CAAO,QAAQ,IAAI,CAAA;AAAA,GARH,EAAA,WAAA,CAAA;AAUlB,EAAA,WAAA,CAAY,QAAQ,SAAS,CAAA;AAC7B,EAAO,OAAA,MAAA;AACT,CAfmC,EAAA,8BAAA,CAAA;AAgBnC,IAAI,mCAAoBA,wBAAA,CAAA,CAAA,QAAA,K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AAE,CAAA,CAAA;AAAA;AAElF,QAAA,IAAI,CAAC,gBAAkB,EAAA;AACrB,UAAM,MAAA,IAAI,MAAM,mFAAmF,CAAA;AAAA;AACrG;AACF,KAbQ,EAAA,UAAA;AAAA,GAeZ;AACF,CArFuD,EAAA,sBAAA,CAAA;AAsF1C,IAAA,MAAA,GAASQ,wBAAe,oBAAoB","file":"chunk-VLAENKR2.cjs","sourcesContent":["// src/index.ts\nimport fs2 from \"fs\";\nimport gql from \"graphql-tag\";\nimport readline2 from \"readline\";\nimport path2 from \"path\";\nvar generateDocumentNodeString = (graphqlDocument, mapDocumentNode) => {\n const documentNodeToUse = mapDocumentNode ? mapDocumentNode(graphqlDocument) : graphqlDocument;\n return JSON.stringify(documentNodeToUse, (key, value) => value === void 0 ? \"__undefined\" : value).replace(/\"__undefined\"/g, \"undefined\");\n};\nvar topologicallySortParsedFiles = (parsedFiles, cache) => {\n const visitedFiles = new Set();\n const sorted = [];\n const visitFile = (file) => {\n if (visitedFiles.has(file))\n return;\n visitedFiles.add(file);\n file.imports.forEach((importFileEntry) => {\n const importedFile = cache[importFileEntry.absolutePath];\n visitFile(importedFile);\n });\n sorted.unshift(file);\n };\n parsedFiles.forEach(visitFile);\n return sorted;\n};\nvar parseGraphQLFile = (filePath) => new Promise((resolve) => {\n const readInterface = readline2.createInterface({\n input: fs2.createReadStream(filePath)\n });\n let body = \"\";\n const imports = [];\n let hasExhaustedImports = false;\n const parseImportAndCapture = (importCommentPrefix, line) => {\n const relativePath = line.replace(importCommentPrefix, \"\");\n const relativePathWithoutQuotations = relativePath.replace(/\"|'/g, \"\");\n const absolutePath = path2.join(path2.dirname(filePath), relativePathWithoutQuotations);\n imports.push({\n absolutePath,\n relativePath\n });\n };\n readInterface.on(\"line\", (line) => {\n if (line.startsWith(\"#import \")) {\n parseImportAndCapture(\"#import \", line);\n } else if (line.startsWith(\"# import \")) {\n parseImportAndCapture(\"# import \", line);\n } else if (hasExhaustedImports) {\n body += line + \"\\n\";\n } else if (line[0] !== \"#\" && line !== \"\") {\n hasExhaustedImports = true;\n body += line + \"\\n\";\n }\n });\n readInterface.on(\"close\", () => {\n resolve({body: body.trim(), filePath, imports});\n });\n});\nvar generateGraphQLString = (entryPointPath) => {\n const cache = {};\n const parsePromises = [];\n const seenImportPaths = new Set();\n const visitAndParse = (filePath) => {\n if (cache[filePath])\n return Promise.resolve(null);\n return new Promise((resolve) => {\n parseGraphQLFile(filePath).then((parsedFile) => {\n cache[parsedFile.filePath] = parsedFile;\n parsedFile.imports.forEach((importEntry) => {\n if (!seenImportPaths.has(importEntry.absolutePath)) {\n seenImportPaths.add(importEntry.absolutePath);\n parsePromises.push(visitAndParse(importEntry.absolutePath));\n }\n });\n const nextPromise = parsePromises.shift();\n if (nextPromise) {\n return nextPromise.then(resolve);\n }\n return resolve(null);\n });\n });\n };\n return visitAndParse(entryPointPath).then(() => {\n const files = topologicallySortParsedFiles(Object.values(cache), cache);\n const graphqlString = files.reduce((accumulator, file) => {\n return file.body + \"\\n\\n\" + accumulator;\n }, \"\");\n return graphqlString;\n });\n};\nvar generateDocumentNodeStringForOperationDefinition = (operationDefinition, fragments, mapDocumentNode) => {\n const operationDocument = {\n kind: \"Document\",\n definitions: [operationDefinition, ...fragments]\n };\n return generateDocumentNodeString(operationDocument, mapDocumentNode);\n};\nvar collectAllFragmentDefinitions = (documentNode) => {\n const accumulateAllFragments = (nodes, accumulator) => {\n nodes.forEach((node) => {\n if (node.kind === \"FragmentDefinition\") {\n accumulator[node.name.value] = node;\n }\n });\n return accumulator;\n };\n return accumulateAllFragments(documentNode.definitions, {});\n};\nvar collectAllFragmentReferences = (node, allFragments) => {\n const references = [];\n const handleSelectionNode = (selection) => {\n if (selection.kind === \"FragmentSpread\") {\n const fragment = allFragments[selection.name.value];\n const innerFragmentReferences = collectAllFragmentReferences(fragment, allFragments);\n references.push(...innerFragmentReferences, selection.name.value);\n }\n };\n if (node.kind === \"OperationDefinition\") {\n node.selectionSet.selections.forEach((selection) => {\n var _a;\n if (selection.kind === \"Field\") {\n (_a = selection.selectionSet) == null ? void 0 : _a.selections.forEach(handleSelectionNode);\n }\n });\n } else {\n node.selectionSet.selections.forEach(handleSelectionNode);\n }\n return references;\n};\nvar generateContentsFromGraphqlString = (graphqlString, mapDocumentNode) => {\n const graphqlDocument = gql(graphqlString);\n const documentNodeAsString = generateDocumentNodeString(graphqlDocument, mapDocumentNode);\n const allFragments = collectAllFragmentDefinitions(graphqlDocument);\n const lines = graphqlDocument.definitions.reduce((accumulator, definition) => {\n if (definition.kind === \"OperationDefinition\" && definition.name && definition.name.value) {\n const name = definition.name.value;\n const fragmentsForOperation = collectAllFragmentReferences(definition, allFragments);\n const fragments = fragmentsForOperation.map((fragmentForOperation) => {\n const fragment = allFragments[fragmentForOperation];\n if (!fragment) {\n throw new Error(`Expected to find fragment definition for ${fragmentForOperation}`);\n }\n return fragment;\n });\n const operationDocumentString = generateDocumentNodeStringForOperationDefinition(definition, fragments, mapDocumentNode);\n accumulator.push(`export const ${name} = ${operationDocumentString};`);\n }\n return accumulator;\n }, [`const documentNode = ${documentNodeAsString};`]);\n lines.push(`export default documentNode;`);\n return lines.join(\"\\n\");\n};\nvar graphqlLoaderPlugin = (options = {}) => ({\n name: \"graphql-loader\",\n setup(build) {\n build.onLoad({filter: options.filterRegex || /\\.graphql$|\\.gql$/}, (args) => generateGraphQLString(args.path).then((graphqlString) => ({\n contents: generateContentsFromGraphqlString(graphqlString, options.mapDocumentNode)\n })));\n }\n});\nvar src_default = graphqlLoaderPlugin;\nexport {\n src_default as default,\n generateContentsFromGraphqlString,\n generateGraphQLString\n};\n","import path from 'node:path';\nimport { generateContentsFromGraphqlString, generateGraphQLString } from '@luckycatfactory/esbuild-graphql-loader';\nimport { glob } from 'glob';\nimport type { UnpluginFactory } from 'unplugin';\nimport { createUnplugin } from 'unplugin';\nimport { defaults } from './defaults';\nimport type { Options } from './types';\n\ntype GraphqlFile = {\n path: string;\n name: string;\n};\n\nconst findGraphQLFiles = async (options: { globPattern: string; globIgnore: string }): Promise<GraphqlFile[]> => {\n const files = await glob(options.globPattern, { ignore: options.globIgnore });\n return files.map((file, index) => ({\n path: path.join(process.cwd(), file).replace(/\\\\/g, '/'),\n name: `gql_${index}`,\n }));\n};\n\nconst generateTypedefsFile = (files: GraphqlFile[]) => {\n const importStatements = files.map((f) => `import ${f.name} from '${f.path}';`);\n\n const documentsArray = `[${files.map((f) => f.name).join(', ')}]`;\n\n const code = [...importStatements, `export default ${documentsArray};`];\n return code.join('\\n');\n};\n\nconst graphqlPluginFactory: UnpluginFactory<Options> = (inputOptions, meta) => {\n const options = {\n ...defaults,\n ...inputOptions,\n };\n const log = (message: any, ...args: any) => {\n if (options.debug) {\n console.log('[graphql]:', message, ...args);\n }\n };\n\n if (options.rootDir == null) {\n options.rootDir = process.cwd();\n }\n const rootDir = options.rootDir;\n let graphqlMatched: string[] = [];\n const graphqlImports: string[] = [];\n let importedTypedefs = false;\n log({ options });\n\n const MODULE_ID = '@shellicar/build-graphql/typedefs';\n\n const typedefsPattern = new RegExp(options.typedefsPath);\n\n const matchTypedefs = (id: string) => {\n if (meta.framework === 'vite') {\n return typedefsPattern.test(id);\n }\n return id === MODULE_ID;\n };\n const matchGraphql = (id: string) => {\n return id.endsWith('.graphql');\n };\n\n return {\n name: 'graphql',\n buildStart: async () => {\n log('Build start');\n graphqlMatched = await glob(options.globPattern, { ignore: options.globIgnore });\n },\n resolveId(id) {\n if (matchTypedefs(id)) {\n return id;\n }\n if (matchGraphql(id)) {\n return path.resolve(rootDir, id);\n }\n },\n loadInclude(id) {\n return matchGraphql(id) || matchTypedefs(id);\n },\n load: async (id) => {\n if (matchTypedefs(id)) {\n importedTypedefs = true;\n const files = await findGraphQLFiles(options);\n const code = generateTypedefsFile(files);\n log(`Typedefs: \\`${code}\\``);\n return { code, map: null };\n }\n if (matchGraphql(id)) {\n const absolutePath = path.isAbsolute(id) ? id : path.resolve(rootDir, id);\n const graphqlString = await generateGraphQLString(absolutePath);\n graphqlImports.push(id);\n return {\n code: generateContentsFromGraphqlString(graphqlString, options.mapDocumentNode),\n map: null,\n };\n }\n },\n buildEnd: () => {\n log('Build end', {\n graphqlMatched,\n graphqlImports,\n importedTypedefs,\n });\n if (!options.ignoreErrors) {\n if (graphqlMatched.length === 0) {\n throw new Error(`No GraphQL files found for the pattern: ${options.globPattern}`);\n }\n if (!importedTypedefs) {\n throw new Error('Typedefs not imported. Make sure to import from @shellicar/build-graphql/typedefs');\n }\n }\n },\n };\n};\nexport const plugin = createUnplugin(graphqlPluginFactory);\n"]}
|