@shellicar/build-graphql 0.1.1 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/README.md +26 -16
  2. package/dist/astro.cjs +1 -1
  3. package/dist/astro.js +1 -1
  4. package/dist/chunk-7BERUFQQ.js +1 -0
  5. package/dist/chunk-7BERUFQQ.js.map +1 -0
  6. package/dist/chunk-ATEDB5SU.js +1 -0
  7. package/dist/chunk-ATEDB5SU.js.map +1 -0
  8. package/dist/chunk-EW2HKAE6.cjs +1 -0
  9. package/dist/chunk-EW2HKAE6.cjs.map +1 -0
  10. package/dist/chunk-MROI2TT6.js +1 -0
  11. package/dist/chunk-MROI2TT6.js.map +1 -0
  12. package/dist/chunk-RH3OQU3Q.js +1 -0
  13. package/dist/chunk-RH3OQU3Q.js.map +1 -0
  14. package/dist/chunk-RLK7DPSM.cjs +1 -0
  15. package/dist/chunk-RLK7DPSM.cjs.map +1 -0
  16. package/dist/chunk-UQ7VVNQE.cjs +1 -0
  17. package/dist/chunk-UQ7VVNQE.cjs.map +1 -0
  18. package/dist/chunk-Y4BNFPWL.cjs +1 -0
  19. package/dist/chunk-Y4BNFPWL.cjs.map +1 -0
  20. package/dist/core/defaults.cjs +1 -1
  21. package/dist/core/defaults.d.cts +0 -1
  22. package/dist/core/defaults.d.ts +0 -1
  23. package/dist/core/defaults.js +1 -1
  24. package/dist/core/graphql.cjs +1 -0
  25. package/dist/core/graphql.cjs.map +1 -0
  26. package/dist/core/graphql.d.cts +24 -0
  27. package/dist/core/graphql.d.ts +24 -0
  28. package/dist/core/graphql.js +1 -0
  29. package/dist/core/graphql.js.map +1 -0
  30. package/dist/core/index.cjs +1 -1
  31. package/dist/core/index.js +1 -1
  32. package/dist/core/module.cjs +1 -0
  33. package/dist/core/module.cjs.map +1 -0
  34. package/dist/core/module.d.cts +3 -0
  35. package/dist/core/module.d.ts +3 -0
  36. package/dist/core/module.js +1 -0
  37. package/dist/core/module.js.map +1 -0
  38. package/dist/core/types.d.cts +5 -10
  39. package/dist/core/types.d.ts +5 -10
  40. package/dist/esbuild.cjs +1 -1
  41. package/dist/esbuild.js +1 -1
  42. package/dist/farm.cjs +1 -1
  43. package/dist/farm.js +1 -1
  44. package/dist/index.cjs +1 -1
  45. package/dist/index.js +1 -1
  46. package/dist/nuxt.cjs +1 -1
  47. package/dist/nuxt.cjs.map +1 -1
  48. package/dist/nuxt.js +1 -1
  49. package/dist/nuxt.js.map +1 -1
  50. package/dist/rollup.cjs +1 -1
  51. package/dist/rollup.js +1 -1
  52. package/dist/rspack.cjs +1 -1
  53. package/dist/rspack.js +1 -1
  54. package/dist/vite.cjs +1 -1
  55. package/dist/vite.js +1 -1
  56. package/dist/webpack.cjs +1 -1
  57. package/dist/webpack.js +1 -1
  58. package/package.json +20 -19
  59. package/CHANGELOG.md +0 -14
  60. package/dist/chunk-OLAXA3NW.cjs +0 -1
  61. package/dist/chunk-OLAXA3NW.cjs.map +0 -1
  62. package/dist/chunk-Q6776UY5.js +0 -1
  63. package/dist/chunk-Q6776UY5.js.map +0 -1
  64. package/dist/chunk-QBNFT4HT.js +0 -1
  65. package/dist/chunk-QBNFT4HT.js.map +0 -1
  66. package/dist/chunk-VLAENKR2.cjs +0 -1
  67. package/dist/chunk-VLAENKR2.cjs.map +0 -1
package/README.md CHANGED
@@ -1,21 +1,25 @@
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
- - ⚡️ Supports Vite, Webpack, Rspack, Vue CLI, Rollup, esbuild and more, powered by [unplugin](https://github.com/unjs/unplugin).
5
+ [![npm package](https://img.shields.io/npm/v/@shellicar/build-graphql.svg)](https://npmjs.com/package/@shellicar/build-graphql)
6
+ [![build status](https://github.com/shellicar/build-graphql/actions/workflows/node.js.yml/badge.svg)](https://github.com/shellicar/build-graphql/actions/workflows/node.js.yml)
6
7
 
7
- ## Usage
8
+ ## Installation & Quick Start
8
9
 
9
10
  ```sh
10
- pnpm add -D @shellicar/build-graphql
11
+ npm i --save @shellicar/build-graphql
11
12
  ```
12
13
 
13
- ### With esbuild
14
+ ```sh
15
+ pnpm add @shellicar/build-graphql
16
+ ```
14
17
 
15
18
  ```ts
19
+ // build.ts
16
20
  import GraphQLPlugin from '@shellicar/build-graphql/esbuild'
17
21
 
18
- build({
22
+ await build({
19
23
  // other options
20
24
  plugins: [
21
25
  GraphQLPlugin({
@@ -25,19 +29,25 @@ build({
25
29
  })
26
30
  ```
27
31
 
28
- ### Importing GraphQL Documents
32
+ ```ts
33
+ // vite.config.ts
34
+ import GraphQLPlugin from '@shellicar/build-graphql/vite'
35
+
36
+ export default defineConfig({
37
+ // other options
38
+ plugins: [
39
+ GraphQLPlugin({
40
+ globPattern: 'src/**/*.graphql'
41
+ })
42
+ ],
43
+ });
44
+ ```
29
45
 
30
46
  ```ts
47
+ // main.ts
31
48
  import typedefs from '@shellicar/build-graphql/typedefs'
32
49
  ```
33
50
 
34
- See [playground examples](./packages/playground) for full working implementations.
35
-
36
- ## Options
37
-
38
- See [types.ts](./packages/build-graphql/src/core/types.ts) for detailed options documentation.
39
-
40
- ## Credits
51
+ ## Documentation
41
52
 
42
- - [@luckycatfactory/esbuild-graphql-loader](https://github.com/luckycatfactory/esbuild-graphql-loader)
43
- - [unplugin](https://github.com/unjs/unplugin)
53
+ 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-VLAENKR2.cjs");require("./chunk-OLAXA3NW.cjs");var u=require("./chunk-PK6SKIKE.cjs"),s=u.__name((s=>({name:"build-graphql",hooks:{"astro:config:setup":u.__name((async u=>{u.config.vite.plugins||=[],u.config.vite.plugins.push(e.plugin.vite(s))}),"astro:config:setup")}})),"default");module.exports=s,module.exports=exports.default;//# sourceMappingURL=astro.cjs.map
1
+ "use strict";var e=require("./chunk-EW2HKAE6.cjs");require("./chunk-UQ7VVNQE.cjs"),require("./chunk-RLK7DPSM.cjs"),require("./chunk-Y4BNFPWL.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-QBNFT4HT.js";import"./chunk-Q6776UY5.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
1
+ import{plugin as o}from"./chunk-ATEDB5SU.js";import"./chunk-7BERUFQQ.js";import"./chunk-MROI2TT6.js";import"./chunk-RH3OQU3Q.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
+ 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-RH3OQU3Q.js";import{__name as n}from"./chunk-7QVYU63E.js";import{glob as i}from"glob";import{createUnplugin as l}from"unplugin";var a=n((r=>`\0${r}`),"resolveVirtualId"),d=l(n((l=>{const d={...r,...l},p={debug:d.debug?(r,...o)=>console.debug(`[version] ${r}`,...o):()=>{},error:n(((r,...o)=>console.error(`[version] ${r}`,...o)),"error")};let s=[];const u=[];let g=!1;return p.debug({options:d}),{name:"unplugin-graphql",enforce:"pre",buildStart:n((async()=>{s=await i(d.globPattern,{ignore:d.globIgnore}),p.debug("Matched GraphQL files:",s)}),"buildStart"),resolveId:r=>r===t||r.endsWith(".graphql")?a(r):void 0,load:n((async r=>{if(r===a(t))return g=!0,await o(d,p);const n=await e(r,d,p);return void 0!==n?(u.push(r),n):void 0}),"load"),buildEnd:n((()=>{if(p.debug("Build end",{graphqlMatched:s,graphqlImports:u,importedTypedefs:g}),!d.ignoreErrors){if(0===s.length)throw new Error(`No GraphQL files found for the pattern: ${d.globPattern}`);if(u.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{d as plugin};//# sourceMappingURL=chunk-ATEDB5SU.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/core/index.ts"],"names":[],"mappings":"0QAQA,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;AA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AAA,KAAO,gBAAiB,CAAA,eAAe,CAAG,EAAA;AAC5C,QAAmB,gBAAA,GAAA,IAAA;AACnB,QAAO,OAAA,MAAM,iBAAkB,CAAA,OAAA,EAAS,MAAM,CAAA;AAAA;AAEhD,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,CA9DuD,EAAA,sBAAA,CAAA;AAgE1C,IAAA,MAAA,GAAS,eAAe,oBAAoB","file":"chunk-ATEDB5SU.js","sourcesContent":["import { 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 ? (message?: unknown, ...optionalParams: unknown[]) => console.debug(`[version] ${message}`, ...optionalParams) : () => {};\n const error = (message?: unknown, ...optionalParams: unknown[]) => console.error(`[version] ${message}`, ...optionalParams);\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
+ "use strict";var e=require("./chunk-UQ7VVNQE.cjs"),r=require("./chunk-RLK7DPSM.cjs"),o=require("./chunk-Y4BNFPWL.cjs"),n=require("./chunk-PK6SKIKE.cjs"),t=require("glob"),l=require("unplugin"),i=n.__name((e=>`\0${e}`),"resolveVirtualId"),a=n.__name((l=>{const a={...e.defaults,...l},u={debug:a.debug?(e,...r)=>console.debug(`[version] ${e}`,...r):()=>{},error:n.__name(((e,...r)=>console.error(`[version] ${e}`,...r)),"error")};let d=[];const s=[];let g=!1;return u.debug({options:a}),{name:"unplugin-graphql",enforce:"pre",buildStart:n.__name((async()=>{d=await t.glob(a.globPattern,{ignore:a.globIgnore}),u.debug("Matched GraphQL files:",d)}),"buildStart"),resolveId:e=>e===o.virtualModuleId||e.endsWith(".graphql")?i(e):void 0,load:n.__name((async e=>{if(e===i(o.virtualModuleId))return g=!0,await r.loadVirtualModule(a,u);const n=await r.loadGraphqlModule(e,a,u);return void 0!==n?(s.push(e),n):void 0}),"load"),buildEnd:n.__name((()=>{if(u.debug("Build end",{graphqlMatched:d,graphqlImports:s,importedTypedefs:g}),!a.ignoreErrors){if(0===d.length)throw new Error(`No GraphQL files found for the pattern: ${a.globPattern}`);if(s.length!==d.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"),u=l.createUnplugin(a);exports.plugin=u;//# sourceMappingURL=chunk-EW2HKAE6.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/core/index.ts"],"names":["__name","defaults","glob","virtualModuleId","loadVirtualModule","loadGraphqlModule","createUnplugin"],"mappings":"2QAQA,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,KAAQ,GAAA,CAAC,YAAsB,cAA8B,KAAA,OAAA,CAAQ,KAAM,CAAA,CA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,MAAM,CAAA;AAAA;AAEhD,MAAA,MAAM,MAAS,GAAA,MAAMC,mCAAkB,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,0BAAgBL,wBAAA,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,CA9DuD,EAAA,sBAAA,CAAA;AAgE1C,IAAA,MAAA,GAASM,wBAAe,oBAAoB","file":"chunk-EW2HKAE6.cjs","sourcesContent":["import { 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 ? (message?: unknown, ...optionalParams: unknown[]) => console.debug(`[version] ${message}`, ...optionalParams) : () => {};\n const error = (message?: unknown, ...optionalParams: unknown[]) => console.error(`[version] ${message}`, ...optionalParams);\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{__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,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,SAAA,GAAS,aAAgB,GAAA,KAAK,CAAE,CAAA,OAAA,CAAQ,kBAAkB,WAAW,CAAA;AAC1I,CAHiC,EAAA,4BAAA,CAAA;A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AA,CAAE,IAAK,CAAA,IAAI,CAAC,CAAA,CAAA,CAAA;AAE9D,EAAA,MAAM,OAAO,CAAC,GAAG,gBAAkB,EAAA,CAAA,eAAA,EAAkB,cAAc,CAAG,CAAA,CAAA,CAAA;AACtE,EAAO,OAAA,IAAA,CAAK,KAAK,IAAI,CAAA;AACvB,CAP6B,EAAA,sBAAA,CAAA;AAiBhB,IAAA,iBAAA,mBAA2B,MAAA,CAAA,OAAA,OAAA,EAAsD,MAA8C,KAAA;AAC1I,EAAM,MAAA,KAAA,GAAQ,MAAM,gBAAA,CAAiB,OAAO,CAAA;AAC5C,EAAM,MAAA,IAAA,GAAO,qBAAqB,KAAK,CAAA;AACvC,EAAO,MAAA,CAAA,KAAA,CAAM,CAAe,YAAA,EAAA,IAAI,CAAI,EAAA,CAAA,CAAA;AACpC,EAAO,OAAA,EAAE,IAAM,EAAA,GAAA,EAAK,IAAK,EAAA;AAC3B,CALiC,EAAA,mBAAA;AAO1B,IAAM,iBAAoB,mBAAA,MAAA,CAAA,OAAO,EAAY,EAAA,OAAA,EAA6E,MAA8C,KAAA;AAC7K,EAAA,IAAI,GAAG,UAAW,CAAA,IAAI,KAAK,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-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-RH3OQU3Q.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-RH3OQU3Q.js","sourcesContent":["{\n \"name\": \"@shellicar/build-graphql\",\n \"private\": false,\n \"version\": \"1.0.0\",\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 \"import\": \"./dist/index.js\",\n \"require\": \"./dist/index.cjs\"\n },\n \"./astro\": {\n \"import\": \"./dist/astro.js\",\n \"require\": \"./dist/astro.cjs\"\n },\n \"./rspack\": {\n \"import\": \"./dist/rspack.js\",\n \"require\": \"./dist/rspack.cjs\"\n },\n \"./vite\": {\n \"import\": \"./dist/vite.js\",\n \"require\": \"./dist/vite.cjs\"\n },\n \"./webpack\": {\n \"import\": \"./dist/webpack.js\",\n \"require\": \"./dist/webpack.cjs\"\n },\n \"./rollup\": {\n \"import\": \"./dist/rollup.js\",\n \"require\": \"./dist/rollup.cjs\"\n },\n \"./esbuild\": {\n \"import\": \"./dist/esbuild.js\",\n \"require\": \"./dist/esbuild.cjs\"\n },\n \"./nuxt\": {\n \"import\": \"./dist/nuxt.js\",\n \"require\": \"./dist/nuxt.cjs\"\n },\n \"./farm\": {\n \"import\": \"./dist/farm.js\",\n \"require\": \"./dist/farm.cjs\"\n },\n \"./types\": {\n \"import\": \"./dist/core/types.js\",\n \"require\": \"./dist/core/types.cjs\"\n },\n \"./typedefs\": {\n \"import\": \"./dist/core/typedefs.js\",\n \"require\": \"./dist/core/typedefs.cjs\"\n },\n \"./*\": \"./*\"\n },\n \"main\": \"dist/index.cjs\",\n \"module\": \"dist/index.js\",\n \"types\": \"dist/index.d.ts\",\n \"typesVersions\": {\n \"*\": {\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("path"),t=require("fs"),a=require("graphql-tag"),r=require("readline"),o=require("glob");function i(e){return e&&e.__esModule?e:{default:e}}var l=i(n),s=i(t),u=i(a),c=i(r),d=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"),m=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"),p=e.__name((n=>new Promise((t=>{const a=c.default.createInterface({input:s.default.createReadStream(n)});let r="";const o=[];let i=!1;const u=e.__name(((e,t)=>{const a=t.replace(e,""),r=a.replace(/"|'/g,""),i=l.default.join(l.default.dirname(n),r);o.push({absolutePath:i,relativePath:a})}),"parseImportAndCapture");a.on("line",(e=>{e.startsWith("#import ")?u("#import ",e):e.startsWith("# import ")?u("# 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"),f=e.__name((n=>{const t={},a=[],r=new Set,o=e.__name((e=>t[e]?Promise.resolve(null):new Promise((n=>{p(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((()=>m(Object.values(t),t).reduce(((e,n)=>n.body+"\n\n"+e),"")))}),"generateGraphQLString"),h=e.__name(((e,n,t)=>{const a={kind:"Document",definitions:[e,...n]};return d(a,t)}),"generateDocumentNodeStringForOperationDefinition"),_=e.__name((n=>e.__name(((e,n)=>(e.forEach((e=>{"FragmentDefinition"===e.kind&&(n[e.name.value]=e)})),n)),"accumulateAllFragments")(n.definitions,{})),"collectAllFragmentDefinitions"),g=e.__name(((n,t)=>{const a=[],r=e.__name((e=>{if("FragmentSpread"===e.kind){const n=t[e.name.value],r=g(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"),P=e.__name(((e,n)=>{const t=u.default(e),a=d(t,n),r=_(t),o=t.definitions.reduce(((e,t)=>{if("OperationDefinition"===t.kind&&t.name&&t.name.value){const a=t.name.value,o=g(t,r).map((e=>{const n=r[e];if(!n)throw new Error(`Expected to find fragment definition for ${e}`);return n})),i=h(t,o,n);e.push(`export const ${a} = ${i};`)}return e}),[`const documentNode = ${a};`]);return o.push("export default documentNode;"),o.join("\n")}),"generateContentsFromGraphqlString"),S=e.__name((async e=>(await o.glob(e.globPattern,{ignore:e.globIgnore})).map(((e,n)=>({path:l.default.join(process.cwd(),e).replace(/\\/g,"/"),name:`gql_${n}`})))),"findGraphQLFiles"),v=e.__name((e=>[...e.map((e=>`import ${e.name} from '${e.path}';`)),`export default ${`[${e.map((e=>e.name)).join(", ")}]`};`].join("\n")),"generateTypedefsFile"),F=e.__name((async(e,n)=>{const t=await S(e),a=v(t);return n.debug(`Typedefs: \`${a}\``),{code:a,map:null}}),"loadVirtualModule"),b=e.__name((async(e,n,t)=>{if(e.startsWith("\0")&&e.endsWith(".graphql")){const t=e.slice(1),a=await f(t);return{code:P(a,n.mapDocumentNode),map:null}}}),"loadGraphqlModule");exports.findGraphQLFiles=S,exports.loadGraphqlModule=b,exports.loadVirtualModule=F;//# sourceMappingURL=chunk-RLK7DPSM.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_modules/@luckycatfactory/esbuild-graphql-loader/lib/index.mjs","../src/core/graphql.ts"],"names":["__name","readline2","fs2","path2","gql","glob","path"],"mappings":"sdAKA,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,SAAA,GAAS,aAAgB,GAAA,KAAK,CAAE,CAAA,OAAA,CAAQ,kBAAkB,WAAW,CAAA;AAC1I,CAHiC,EAAA,4BAAA,CAAA;AAIjC,IAAI,4BAAA,mBAAgCA,wBAAA,CAAA,CAAA,WAAA,EA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AI,CAAC,CAAA,CAAA,CAAA;AAE9D,EAAA,MAAM,OAAO,CAAC,GAAG,gBAAkB,EAAA,CAAA,eAAA,EAAkB,cAAc,CAAG,CAAA,CAAA,CAAA;AACtE,EAAO,OAAA,IAAA,CAAK,KAAK,IAAI,CAAA;AACvB,CAP6B,EAAA,sBAAA,CAAA;AAiBhB,IAAA,iBAAA,mBAA2BN,wBAAA,CAAA,OAAA,OAAA,EAAsD,MAA8C,KAAA;AAC1I,EAAM,MAAA,KAAA,GAAQ,MAAM,gBAAA,CAAiB,OAAO,CAAA;AAC5C,EAAM,MAAA,IAAA,GAAO,qBAAqB,KAAK,CAAA;AACvC,EAAO,MAAA,CAAA,KAAA,CAAM,CAAe,YAAA,EAAA,IAAI,CAAI,EAAA,CAAA,CAAA;AACpC,EAAO,OAAA,EAAE,IAAM,EAAA,GAAA,EAAK,IAAK,EAAA;AAC3B,CALiC,EAAA,mBAAA;AAO1B,IAAM,iBAAoB,mBAAAA,wBAAA,CAAA,OAAO,EAAY,EAAA,OAAA,EAA6E,MAA8C,KAAA;AAC7K,EAAA,IAAI,GAAG,UAAW,CAAA,IAAI,KAAK,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-RLK7DPSM.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";exports.virtualModuleId="@shellicar/build-graphql/typedefs";//# sourceMappingURL=chunk-Y4BNFPWL.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-Y4BNFPWL.cjs","sourcesContent":["{\n \"name\": \"@shellicar/build-graphql\",\n \"private\": false,\n \"version\": \"1.0.0\",\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 \"import\": \"./dist/index.js\",\n \"require\": \"./dist/index.cjs\"\n },\n \"./astro\": {\n \"import\": \"./dist/astro.js\",\n \"require\": \"./dist/astro.cjs\"\n },\n \"./rspack\": {\n \"import\": \"./dist/rspack.js\",\n \"require\": \"./dist/rspack.cjs\"\n },\n \"./vite\": {\n \"import\": \"./dist/vite.js\",\n \"require\": \"./dist/vite.cjs\"\n },\n \"./webpack\": {\n \"import\": \"./dist/webpack.js\",\n \"require\": \"./dist/webpack.cjs\"\n },\n \"./rollup\": {\n \"import\": \"./dist/rollup.js\",\n \"require\": \"./dist/rollup.cjs\"\n },\n \"./esbuild\": {\n \"import\": \"./dist/esbuild.js\",\n \"require\": \"./dist/esbuild.cjs\"\n },\n \"./nuxt\": {\n \"import\": \"./dist/nuxt.js\",\n \"require\": \"./dist/nuxt.cjs\"\n },\n \"./farm\": {\n \"import\": \"./dist/farm.js\",\n \"require\": \"./dist/farm.cjs\"\n },\n \"./types\": {\n \"import\": \"./dist/core/types.js\",\n \"require\": \"./dist/core/types.cjs\"\n },\n \"./typedefs\": {\n \"import\": \"./dist/core/typedefs.js\",\n \"require\": \"./dist/core/typedefs.cjs\"\n },\n \"./*\": \"./*\"\n },\n \"main\": \"dist/index.cjs\",\n \"module\": \"dist/index.js\",\n \"types\": \"dist/index.d.ts\",\n \"typesVersions\": {\n \"*\": {\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"]}
@@ -1 +1 @@
1
- "use strict";var e=require("../chunk-OLAXA3NW.cjs");require("../chunk-PK6SKIKE.cjs"),Object.defineProperty(exports,"defaults",{enumerable:!0,get:function(){return e.defaults}});//# sourceMappingURL=defaults.cjs.map
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
@@ -3,7 +3,6 @@ declare const defaults: {
3
3
  readonly globIgnore: "**/node_modules/**";
4
4
  readonly ignoreErrors: false;
5
5
  readonly debug: false;
6
- readonly typedefsPath: "@shellicar/build-graphql/dist/core/typedefs\\.c?js$";
7
6
  };
8
7
 
9
8
  export { defaults };
@@ -3,7 +3,6 @@ declare const defaults: {
3
3
  readonly globIgnore: "**/node_modules/**";
4
4
  readonly ignoreErrors: false;
5
5
  readonly debug: false;
6
- readonly typedefsPath: "@shellicar/build-graphql/dist/core/typedefs\\.c?js$";
7
6
  };
8
7
 
9
8
  export { defaults };
@@ -1 +1 @@
1
- export{defaults}from"../chunk-Q6776UY5.js";import"../chunk-7QVYU63E.js";//# sourceMappingURL=defaults.js.map
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-RLK7DPSM.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"}
@@ -1 +1 @@
1
- "use strict";var e=require("../chunk-VLAENKR2.cjs");require("../chunk-OLAXA3NW.cjs"),require("../chunk-PK6SKIKE.cjs"),Object.defineProperty(exports,"plugin",{enumerable:!0,get:function(){return e.plugin}});//# sourceMappingURL=index.cjs.map
1
+ "use strict";var e=require("../chunk-EW2HKAE6.cjs");require("../chunk-UQ7VVNQE.cjs"),require("../chunk-RLK7DPSM.cjs"),require("../chunk-Y4BNFPWL.cjs"),require("../chunk-PK6SKIKE.cjs"),Object.defineProperty(exports,"plugin",{enumerable:!0,get:function(){return e.plugin}});//# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- export{plugin}from"../chunk-QBNFT4HT.js";import"../chunk-Q6776UY5.js";import"../chunk-7QVYU63E.js";//# sourceMappingURL=index.js.map
1
+ export{plugin}from"../chunk-ATEDB5SU.js";import"../chunk-7BERUFQQ.js";import"../chunk-MROI2TT6.js";import"../chunk-RH3OQU3Q.js";import"../chunk-7QVYU63E.js";//# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ "use strict";var e=require("../chunk-Y4BNFPWL.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,3 @@
1
+ declare const virtualModuleId: string;
2
+
3
+ export { virtualModuleId };
@@ -0,0 +1,3 @@
1
+ declare const virtualModuleId: string;
2
+
3
+ export { virtualModuleId };
@@ -0,0 +1 @@
1
+ export{virtualModuleId}from"../chunk-RH3OQU3Q.js";import"../chunk-7QVYU63E.js";//# sourceMappingURL=module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"module.js"}
@@ -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 };
@@ -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-VLAENKR2.cjs");require("./chunk-OLAXA3NW.cjs"),require("./chunk-PK6SKIKE.cjs");var r=e.plugin.esbuild;module.exports=r,module.exports=exports.default;//# sourceMappingURL=esbuild.cjs.map
1
+ "use strict";var e=require("./chunk-EW2HKAE6.cjs");require("./chunk-UQ7VVNQE.cjs"),require("./chunk-RLK7DPSM.cjs"),require("./chunk-Y4BNFPWL.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-QBNFT4HT.js";import"./chunk-Q6776UY5.js";import"./chunk-7QVYU63E.js";var o=r.esbuild;export{o as default};//# sourceMappingURL=esbuild.js.map
1
+ import{plugin as r}from"./chunk-ATEDB5SU.js";import"./chunk-7BERUFQQ.js";import"./chunk-MROI2TT6.js";import"./chunk-RH3OQU3Q.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-VLAENKR2.cjs");require("./chunk-OLAXA3NW.cjs"),require("./chunk-PK6SKIKE.cjs");var r=e.plugin.farm;module.exports=r,module.exports=exports.default;//# sourceMappingURL=farm.cjs.map
1
+ "use strict";var e=require("./chunk-EW2HKAE6.cjs");require("./chunk-UQ7VVNQE.cjs"),require("./chunk-RLK7DPSM.cjs"),require("./chunk-Y4BNFPWL.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-QBNFT4HT.js";import"./chunk-Q6776UY5.js";import"./chunk-7QVYU63E.js";var m=r.farm;export{m as default};//# sourceMappingURL=farm.js.map
1
+ import{plugin as r}from"./chunk-ATEDB5SU.js";import"./chunk-7BERUFQQ.js";import"./chunk-MROI2TT6.js";import"./chunk-RH3OQU3Q.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-VLAENKR2.cjs");require("./chunk-OLAXA3NW.cjs"),require("./chunk-PK6SKIKE.cjs"),module.exports=e.plugin,module.exports=exports.default;//# sourceMappingURL=index.cjs.map
1
+ "use strict";require("./chunk-H44HDUOM.cjs");var e=require("./chunk-EW2HKAE6.cjs");require("./chunk-UQ7VVNQE.cjs"),require("./chunk-RLK7DPSM.cjs"),require("./chunk-Y4BNFPWL.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-QBNFT4HT.js";import"./chunk-Q6776UY5.js";import"./chunk-7QVYU63E.js";//# sourceMappingURL=index.js.map
1
+ import"./chunk-QZKD24XZ.js";export{plugin as default}from"./chunk-ATEDB5SU.js";import"./chunk-7BERUFQQ.js";import"./chunk-MROI2TT6.js";import"./chunk-RH3OQU3Q.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-VLAENKR2.cjs");require("./chunk-OLAXA3NW.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
1
+ "use strict";require("./chunk-H44HDUOM.cjs");var e=require("./chunk-EW2HKAE6.cjs");require("./chunk-UQ7VVNQE.cjs"),require("./chunk-RLK7DPSM.cjs"),require("./chunk-Y4BNFPWL.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":"wNAKA,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"]}
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-QBNFT4HT.js";import"./chunk-Q6776UY5.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
1
+ import"./chunk-QZKD24XZ.js";import{plugin as t}from"./chunk-ATEDB5SU.js";import"./chunk-7BERUFQQ.js";import"./chunk-MROI2TT6.js";import"./chunk-RH3OQU3Q.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":"0NAKA,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"]}
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-VLAENKR2.cjs");require("./chunk-OLAXA3NW.cjs"),require("./chunk-PK6SKIKE.cjs");var r=e.plugin.rollup;module.exports=r,module.exports=exports.default;//# sourceMappingURL=rollup.cjs.map
1
+ "use strict";var e=require("./chunk-EW2HKAE6.cjs");require("./chunk-UQ7VVNQE.cjs"),require("./chunk-RLK7DPSM.cjs"),require("./chunk-Y4BNFPWL.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-QBNFT4HT.js";import"./chunk-Q6776UY5.js";import"./chunk-7QVYU63E.js";var o=r.rollup;export{o as default};//# sourceMappingURL=rollup.js.map
1
+ import{plugin as r}from"./chunk-ATEDB5SU.js";import"./chunk-7BERUFQQ.js";import"./chunk-MROI2TT6.js";import"./chunk-RH3OQU3Q.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-VLAENKR2.cjs");require("./chunk-OLAXA3NW.cjs"),require("./chunk-PK6SKIKE.cjs");var r=e.plugin.rspack;module.exports=r,module.exports=exports.default;//# sourceMappingURL=rspack.cjs.map
1
+ "use strict";var e=require("./chunk-EW2HKAE6.cjs");require("./chunk-UQ7VVNQE.cjs"),require("./chunk-RLK7DPSM.cjs"),require("./chunk-Y4BNFPWL.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-QBNFT4HT.js";import"./chunk-Q6776UY5.js";import"./chunk-7QVYU63E.js";var o=r.rspack;export{o as default};//# sourceMappingURL=rspack.js.map
1
+ import{plugin as r}from"./chunk-ATEDB5SU.js";import"./chunk-7BERUFQQ.js";import"./chunk-MROI2TT6.js";import"./chunk-RH3OQU3Q.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-VLAENKR2.cjs");require("./chunk-OLAXA3NW.cjs"),require("./chunk-PK6SKIKE.cjs");var r=e.plugin.vite;module.exports=r,module.exports=exports.default;//# sourceMappingURL=vite.cjs.map
1
+ "use strict";var e=require("./chunk-EW2HKAE6.cjs");require("./chunk-UQ7VVNQE.cjs"),require("./chunk-RLK7DPSM.cjs"),require("./chunk-Y4BNFPWL.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-QBNFT4HT.js";import"./chunk-Q6776UY5.js";import"./chunk-7QVYU63E.js";var t=r.vite;export{t as default};//# sourceMappingURL=vite.js.map
1
+ import{plugin as r}from"./chunk-ATEDB5SU.js";import"./chunk-7BERUFQQ.js";import"./chunk-MROI2TT6.js";import"./chunk-RH3OQU3Q.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-VLAENKR2.cjs");require("./chunk-OLAXA3NW.cjs"),require("./chunk-PK6SKIKE.cjs");var r=e.plugin.webpack;module.exports=r,module.exports=exports.default;//# sourceMappingURL=webpack.cjs.map
1
+ "use strict";var e=require("./chunk-EW2HKAE6.cjs");require("./chunk-UQ7VVNQE.cjs"),require("./chunk-RLK7DPSM.cjs"),require("./chunk-Y4BNFPWL.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-QBNFT4HT.js";import"./chunk-Q6776UY5.js";import"./chunk-7QVYU63E.js";var o=r.webpack;export{o as default};//# sourceMappingURL=webpack.js.map
1
+ import{plugin as r}from"./chunk-ATEDB5SU.js";import"./chunk-7BERUFQQ.js";import"./chunk-MROI2TT6.js";import"./chunk-RH3OQU3Q.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.0",
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
- "homepage": "https://github.com/shellicar/build-graphql#readme",
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,15 +20,10 @@
12
20
  "bugs": {
13
21
  "url": "https://github.com/shellicar/build-graphql/issues"
14
22
  },
15
- "keywords": [
16
- "build",
17
- "version",
18
- "esbuild",
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
29
  "import": "./dist/index.js",
@@ -83,9 +86,6 @@
83
86
  "dist",
84
87
  "*.md"
85
88
  ],
86
- "publishConfig": {
87
- "access": "public"
88
- },
89
89
  "peerDependencies": {
90
90
  "@farmfe/core": ">=1",
91
91
  "@nuxt/kit": "^3",
@@ -120,8 +120,8 @@
120
120
  },
121
121
  "devDependencies": {
122
122
  "@luckycatfactory/esbuild-graphql-loader": "^3.8.1",
123
- "@nuxt/kit": "^3.15.0",
124
- "@nuxt/schema": "^3.15.0",
123
+ "@nuxt/kit": "^3.15.1",
124
+ "@nuxt/schema": "^3.15.1",
125
125
  "@tsconfig/node20": "^20.1.4",
126
126
  "@types/node": "^22.10.5",
127
127
  "bumpp": "^9.9.2",
@@ -129,7 +129,7 @@
129
129
  "esno": "^4.8.0",
130
130
  "npm-check-updates": "^17.1.13",
131
131
  "npm-run-all2": "^7.0.2",
132
- "rollup": "^4.29.1",
132
+ "rollup": "^4.30.0",
133
133
  "terser": "^5.37.0",
134
134
  "tsup": "^8.3.5",
135
135
  "vite": "^6.0.7",
@@ -144,6 +144,7 @@
144
144
  },
145
145
  "scripts": {
146
146
  "build": "tsup",
147
- "dev": "tsup --watch src"
147
+ "dev": "tsup --watch",
148
+ "type-check": "tsc -p tsconfig.check.json"
148
149
  }
149
150
  }
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
@@ -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"]}
@@ -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"]}
@@ -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,S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,CAAA;AAC9D,QAAA,cAAA,CAAe,KAAK,EAAE,CAAA;AACtB,QAAO,OAAA;AAAA,UACL,IAAM,EAAA,iCAAA,CAAkC,aAAe,EAAA,OAAA,CAAQ,eAAe,CAAA;AAAA,UAC9E,GAAK,EAAA;AAAA,SACP;AAAA;AACF,KAhBI,EAAA,MAAA,CAAA;AAAA,IAkBN,0BAAgB,MAAA,CAAA,MAAA;AACd,MAAA,GAAA,CAAI,WAAa,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"]}
@@ -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,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AAA;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,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"]}