@graphql-codegen/cli 7.1.1 → 7.1.2-alpha-20260531121708-9fbdcfaf6bf0b7951b9e1bee9a2e2d173e3a7edf

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/cjs/config.js CHANGED
@@ -13,6 +13,7 @@ const tslib_1 = require("tslib");
13
13
  const crypto_1 = require("crypto");
14
14
  const fs_1 = require("fs");
15
15
  const module_1 = require("module");
16
+ const url = tslib_1.__importStar(require("node:url"));
16
17
  const path_1 = require("path");
17
18
  const cosmiconfig_1 = require("cosmiconfig");
18
19
  const graphql_1 = require("graphql");
@@ -198,9 +199,9 @@ function parseArgv(argv = process.argv) {
198
199
  async function createContext(cliFlags = parseArgv(process.argv)) {
199
200
  if (cliFlags.require && cliFlags.require.length > 0) {
200
201
  const relativeRequire = (0, module_1.createRequire)(process.cwd());
201
- await Promise.all(cliFlags.require.map(mod => Promise.resolve(`${relativeRequire.resolve(mod, {
202
+ await Promise.all(cliFlags.require.map(mod => safeDynamicImport(relativeRequire.resolve(mod, {
202
203
  paths: [process.cwd()],
203
- })}`).then(s => tslib_1.__importStar(require(s)))));
204
+ }))));
204
205
  }
205
206
  const customConfigPath = getCustomConfigPath(cliFlags);
206
207
  const context = await loadContext(customConfigPath);
@@ -382,3 +383,13 @@ async function addMetadataToSources(documentFilesPromise, type) {
382
383
  return doc;
383
384
  }));
384
385
  }
386
+ /**
387
+ * `safeDynamicImport` is a wrapper of dynamic `import()` to work across MacOS and Windows
388
+ * On native Windows (i.e. no WSL or CI), a filename may look like this: `C:\\Users\\path\\to\\file.ts`
389
+ * If used directly with `import()`, we'll see `ERR_UNSUPPORTED_ESM_URL_SCHEME` error because C: is not a valid protocol
390
+ * `url.pathToFileURL` turns the filename to `fil:///C:/Users/path/to/file.ts`, which is import-able
391
+ */
392
+ const safeDynamicImport = (absoluteFilename) => {
393
+ const { href: fileUrl } = url.pathToFileURL(absoluteFilename);
394
+ return Promise.resolve(`${fileUrl}`).then(s => tslib_1.__importStar(require(s)));
395
+ };
package/cjs/version.js CHANGED
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.version = void 0;
4
- exports.version = '7.1.1';
4
+ exports.version = '7.1.2-alpha-20260531121708-9fbdcfaf6bf0b7951b9e1bee9a2e2d173e3a7edf';
package/esm/config.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { createHash } from 'crypto';
2
2
  import { promises } from 'fs';
3
3
  import { createRequire } from 'module';
4
+ import * as url from 'node:url';
4
5
  import { resolve } from 'path';
5
6
  import { cosmiconfig, defaultLoaders } from 'cosmiconfig';
6
7
  import { print } from 'graphql';
@@ -186,7 +187,7 @@ export function parseArgv(argv = process.argv) {
186
187
  export async function createContext(cliFlags = parseArgv(process.argv)) {
187
188
  if (cliFlags.require && cliFlags.require.length > 0) {
188
189
  const relativeRequire = createRequire(process.cwd());
189
- await Promise.all(cliFlags.require.map(mod => import(relativeRequire.resolve(mod, {
190
+ await Promise.all(cliFlags.require.map(mod => safeDynamicImport(relativeRequire.resolve(mod, {
190
191
  paths: [process.cwd()],
191
192
  }))));
192
193
  }
@@ -369,3 +370,13 @@ async function addMetadataToSources(documentFilesPromise, type) {
369
370
  return doc;
370
371
  }));
371
372
  }
373
+ /**
374
+ * `safeDynamicImport` is a wrapper of dynamic `import()` to work across MacOS and Windows
375
+ * On native Windows (i.e. no WSL or CI), a filename may look like this: `C:\\Users\\path\\to\\file.ts`
376
+ * If used directly with `import()`, we'll see `ERR_UNSUPPORTED_ESM_URL_SCHEME` error because C: is not a valid protocol
377
+ * `url.pathToFileURL` turns the filename to `fil:///C:/Users/path/to/file.ts`, which is import-able
378
+ */
379
+ const safeDynamicImport = (absoluteFilename) => {
380
+ const { href: fileUrl } = url.pathToFileURL(absoluteFilename);
381
+ return import(fileUrl);
382
+ };
package/esm/version.js CHANGED
@@ -1 +1 @@
1
- export const version = '7.1.1';
1
+ export const version = '7.1.2-alpha-20260531121708-9fbdcfaf6bf0b7951b9e1bee9a2e2d173e3a7edf';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-codegen/cli",
3
- "version": "7.1.1",
3
+ "version": "7.1.2-alpha-20260531121708-9fbdcfaf6bf0b7951b9e1bee9a2e2d173e3a7edf",
4
4
  "peerDependenciesMeta": {
5
5
  "@parcel/watcher": {
6
6
  "optional": true