@graphql-codegen/cli 2.9.0-alpha-78f7f741b.0 → 2.9.1-alpha-fca07d28c.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/cli.js CHANGED
@@ -40,7 +40,6 @@ async function runCli(cmd) {
40
40
  }
41
41
  catch (error) {
42
42
  await (0, hooks_js_1.lifecycleHooks)(context.getConfig().hooks).onError(error.toString());
43
- throw error;
44
43
  }
45
44
  }
46
45
  exports.runCli = runCli;
package/cjs/codegen.js CHANGED
@@ -239,6 +239,7 @@ async function executeCodegen(input) {
239
239
  ...(typeof outputFileTemplateConfig === 'string'
240
240
  ? { value: outputFileTemplateConfig }
241
241
  : outputFileTemplateConfig),
242
+ emitLegacyCommonJSImports: (0, config_js_1.shouldEmitLegacyCommonJSImports)(config, filename),
242
243
  };
243
244
  const outputs = hasPreset
244
245
  ? await context.profiler.run(async () => preset.buildGeneratesSection({
@@ -268,7 +269,10 @@ async function executeCodegen(input) {
268
269
  ];
269
270
  const process = async (outputArgs) => {
270
271
  const output = await (0, core_1.codegen)({
271
- ...outputArgs,
272
+ ...{
273
+ ...outputArgs,
274
+ emitLegacyCommonJSImports: (0, config_js_1.shouldEmitLegacyCommonJSImports)(config, outputArgs.filename),
275
+ },
272
276
  cache,
273
277
  });
274
278
  result.push({
package/cjs/config.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ensureContext = exports.CodegenContext = exports.updateContextWithCliFlags = exports.createContext = exports.parseArgv = exports.buildOptions = exports.loadContext = exports.loadCodegenConfig = exports.generateSearchPlaces = void 0;
3
+ exports.shouldEmitLegacyCommonJSImports = exports.ensureContext = exports.CodegenContext = exports.updateContextWithCliFlags = exports.createContext = exports.parseArgv = exports.buildOptions = exports.loadContext = exports.loadCodegenConfig = exports.generateSearchPlaces = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const cosmiconfig_1 = require("cosmiconfig");
6
6
  const path_1 = require("path");
@@ -309,3 +309,16 @@ function addHashToDocumentFiles(documentFilesPromise) {
309
309
  return doc;
310
310
  }));
311
311
  }
312
+ function shouldEmitLegacyCommonJSImports(config, outputPath) {
313
+ const globalValue = config.emitLegacyCommonJSImports === undefined ? true : !!config.emitLegacyCommonJSImports;
314
+ // const outputConfig = config.generates[outputPath];
315
+ // if (!outputConfig) {
316
+ // debugLog(`Couldn't find a config of ${outputPath}`);
317
+ // return globalValue;
318
+ // }
319
+ // if (isConfiguredOutput(outputConfig) && typeof outputConfig.emitLegacyCommonJSImports === 'boolean') {
320
+ // return outputConfig.emitLegacyCommonJSImports;
321
+ // }
322
+ return globalValue;
323
+ }
324
+ exports.shouldEmitLegacyCommonJSImports = shouldEmitLegacyCommonJSImports;
package/cjs/plugins.js CHANGED
@@ -21,7 +21,7 @@ async function getPluginByName(name, pluginLoader) {
21
21
  return await pluginLoader(moduleName);
22
22
  }
23
23
  catch (err) {
24
- if (err.code !== 'MODULE_NOT_FOUND') {
24
+ if (err.code !== 'MODULE_NOT_FOUND' && err.code !== 'ERR_MODULE_NOT_FOUND') {
25
25
  throw new plugin_helpers_1.DetailedError(`Unable to load template plugin matching ${name}`, `
26
26
  Unable to load template plugin matching '${name}'.
27
27
  Reason:
package/esm/cli.js CHANGED
@@ -14,7 +14,6 @@ export async function runCli(cmd) {
14
14
  }
15
15
  catch (error) {
16
16
  await lifecycleHooks(context.getConfig().hooks).onError(error.toString());
17
- throw error;
18
17
  }
19
18
  }
20
19
  export async function ensureGraphQlPackage() {
package/esm/codegen.js CHANGED
@@ -5,7 +5,7 @@ import { GraphQLError } from 'graphql';
5
5
  import { getPluginByName } from './plugins.js';
6
6
  import { getPresetByName } from './presets.js';
7
7
  import { debugLog } from './utils/debugging.js';
8
- import { ensureContext } from './config.js';
8
+ import { ensureContext, shouldEmitLegacyCommonJSImports } from './config.js';
9
9
  import fs from 'fs';
10
10
  import path from 'path';
11
11
  import { cpus } from 'os';
@@ -235,6 +235,7 @@ export async function executeCodegen(input) {
235
235
  ...(typeof outputFileTemplateConfig === 'string'
236
236
  ? { value: outputFileTemplateConfig }
237
237
  : outputFileTemplateConfig),
238
+ emitLegacyCommonJSImports: shouldEmitLegacyCommonJSImports(config, filename),
238
239
  };
239
240
  const outputs = hasPreset
240
241
  ? await context.profiler.run(async () => preset.buildGeneratesSection({
@@ -264,7 +265,10 @@ export async function executeCodegen(input) {
264
265
  ];
265
266
  const process = async (outputArgs) => {
266
267
  const output = await codegen({
267
- ...outputArgs,
268
+ ...{
269
+ ...outputArgs,
270
+ emitLegacyCommonJSImports: shouldEmitLegacyCommonJSImports(config, outputArgs.filename),
271
+ },
268
272
  cache,
269
273
  });
270
274
  result.push({
package/esm/config.js CHANGED
@@ -296,3 +296,15 @@ function addHashToDocumentFiles(documentFilesPromise) {
296
296
  return doc;
297
297
  }));
298
298
  }
299
+ export function shouldEmitLegacyCommonJSImports(config, outputPath) {
300
+ const globalValue = config.emitLegacyCommonJSImports === undefined ? true : !!config.emitLegacyCommonJSImports;
301
+ // const outputConfig = config.generates[outputPath];
302
+ // if (!outputConfig) {
303
+ // debugLog(`Couldn't find a config of ${outputPath}`);
304
+ // return globalValue;
305
+ // }
306
+ // if (isConfiguredOutput(outputConfig) && typeof outputConfig.emitLegacyCommonJSImports === 'boolean') {
307
+ // return outputConfig.emitLegacyCommonJSImports;
308
+ // }
309
+ return globalValue;
310
+ }
package/esm/plugins.js CHANGED
@@ -18,7 +18,7 @@ export async function getPluginByName(name, pluginLoader) {
18
18
  return await pluginLoader(moduleName);
19
19
  }
20
20
  catch (err) {
21
- if (err.code !== 'MODULE_NOT_FOUND') {
21
+ if (err.code !== 'MODULE_NOT_FOUND' && err.code !== 'ERR_MODULE_NOT_FOUND') {
22
22
  throw new DetailedError(`Unable to load template plugin matching ${name}`, `
23
23
  Unable to load template plugin matching '${name}'.
24
24
  Reason:
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@graphql-codegen/cli",
3
- "version": "2.9.0-alpha-78f7f741b.0",
3
+ "version": "2.9.1-alpha-fca07d28c.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.6.1-alpha-78f7f741b.0",
9
- "@graphql-codegen/plugin-helpers": "^2.6.0-alpha-78f7f741b.0",
8
+ "@graphql-codegen/core": "2.6.0",
9
+ "@graphql-codegen/plugin-helpers": "^2.6.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",
@@ -33,6 +33,7 @@
33
33
  "mkdirp": "^1.0.4",
34
34
  "string-env-interpolation": "^1.0.1",
35
35
  "ts-log": "^2.2.3",
36
+ "tslib": "^2.4.0",
36
37
  "yaml": "^1.10.0",
37
38
  "yargs": "^17.0.0"
38
39
  },
@@ -116,3 +116,4 @@ export declare class CodegenContext {
116
116
  loadDocuments(pointer: Types.OperationDocument[]): Promise<Types.DocumentFile[]>;
117
117
  }
118
118
  export declare function ensureContext(input: CodegenContext | Types.Config): CodegenContext;
119
+ export declare function shouldEmitLegacyCommonJSImports(config: Types.Config, outputPath: string): boolean;