@graphql-codegen/cli 2.8.0-alpha-5cf64cf6a.0 → 2.8.0-alpha-2fbcdb6d3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/cjs/codegen.js CHANGED
@@ -14,17 +14,29 @@ const config_js_1 = require("./config.js");
14
14
  const fs_1 = tslib_1.__importDefault(require("fs"));
15
15
  const path_1 = tslib_1.__importDefault(require("path"));
16
16
  const os_1 = require("os");
17
- // eslint-disable-next-line
18
17
  const module_1 = require("module");
19
18
  const listr_1 = tslib_1.__importDefault(require("listr"));
20
19
  const cli_error_js_1 = require("./utils/cli-error.js");
20
+ /**
21
+ * Poor mans ESM detection.
22
+ * Looking at this and you have a better method?
23
+ * Send a PR.
24
+ */
25
+ const isESMModule = (typeof __dirname === 'string') === false;
21
26
  const makeDefaultLoader = (from) => {
22
27
  if (fs_1.default.statSync(from).isDirectory()) {
23
28
  from = path_1.default.join(from, '__fake.js');
24
29
  }
25
30
  const relativeRequire = (0, module_1.createRequire)(from);
26
- return (mod) => {
27
- return Promise.resolve().then(() => tslib_1.__importStar(require(relativeRequire.resolve(mod))));
31
+ return async (mod) => {
32
+ return Promise.resolve().then(() => tslib_1.__importStar(require(isESMModule
33
+ ? /**
34
+ * For ESM we currently have no "resolve path" solution
35
+ * as import.meta is unavailable in a CommonJS context
36
+ * and furthermore unavailable in stable Node.js.
37
+ **/
38
+ mod
39
+ : relativeRequire.resolve(mod))));
28
40
  };
29
41
  };
30
42
  function createCache() {
package/cjs/presets.js CHANGED
@@ -22,7 +22,11 @@ async function getPresetByName(name, loader) {
22
22
  return loaded;
23
23
  }
24
24
  catch (err) {
25
- if (err.code !== 'MODULE_NOT_FOUND') {
25
+ if (
26
+ /** CJS Error code */
27
+ err.code !== 'MODULE_NOT_FOUND' &&
28
+ /** ESM Error code */
29
+ err.code !== 'ERR_MODULE_NOT_FOUND') {
26
30
  throw new plugin_helpers_1.DetailedError(`Unable to load preset matching ${name}`, `
27
31
  Unable to load preset matching '${name}'.
28
32
  Reason:
package/esm/codegen.js CHANGED
@@ -10,17 +10,29 @@ import { ensureContext } from './config.js';
10
10
  import fs from 'fs';
11
11
  import path from 'path';
12
12
  import { cpus } from 'os';
13
- // eslint-disable-next-line
14
13
  import { createRequire } from 'module';
15
14
  import Listr from 'listr';
16
15
  import { isListrError } from './utils/cli-error.js';
16
+ /**
17
+ * Poor mans ESM detection.
18
+ * Looking at this and you have a better method?
19
+ * Send a PR.
20
+ */
21
+ const isESMModule = (typeof __dirname === 'string') === false;
17
22
  const makeDefaultLoader = (from) => {
18
23
  if (fs.statSync(from).isDirectory()) {
19
24
  from = path.join(from, '__fake.js');
20
25
  }
21
26
  const relativeRequire = createRequire(from);
22
- return (mod) => {
23
- return import(relativeRequire.resolve(mod));
27
+ return async (mod) => {
28
+ return import(isESMModule
29
+ ? /**
30
+ * For ESM we currently have no "resolve path" solution
31
+ * as import.meta is unavailable in a CommonJS context
32
+ * and furthermore unavailable in stable Node.js.
33
+ **/
34
+ mod
35
+ : relativeRequire.resolve(mod));
24
36
  };
25
37
  };
26
38
  function createCache() {
package/esm/presets.js CHANGED
@@ -19,7 +19,11 @@ export async function getPresetByName(name, loader) {
19
19
  return loaded;
20
20
  }
21
21
  catch (err) {
22
- if (err.code !== 'MODULE_NOT_FOUND') {
22
+ if (
23
+ /** CJS Error code */
24
+ err.code !== 'MODULE_NOT_FOUND' &&
25
+ /** ESM Error code */
26
+ err.code !== 'ERR_MODULE_NOT_FOUND') {
23
27
  throw new DetailedError(`Unable to load preset matching ${name}`, `
24
28
  Unable to load preset matching '${name}'.
25
29
  Reason:
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@graphql-codegen/cli",
3
- "version": "2.8.0-alpha-5cf64cf6a.0",
3
+ "version": "2.8.0-alpha-2fbcdb6d3.0",
4
4
  "peerDependencies": {
5
5
  "graphql": "^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0"
6
6
  },
7
7
  "dependencies": {
8
- "@graphql-codegen/core": "2.5.1",
9
- "@graphql-codegen/plugin-helpers": "^2.4.1",
8
+ "@graphql-codegen/core": "2.6.0-alpha-2fbcdb6d3.0",
9
+ "@graphql-codegen/plugin-helpers": "^2.5.0-alpha-2fbcdb6d3.0",
10
10
  "@graphql-tools/apollo-engine-loader": "^7.3.1",
11
11
  "@graphql-tools/code-file-loader": "^7.3.0",
12
12
  "@graphql-tools/git-loader": "^7.2.0",