From 44eec8d3e17fbc983fa2ecbeda51fcc3d9ee330d Mon Sep 17 00:00:00 2001 From: Arda TANRIKULU Date: Tue, 24 May 2022 15:21:46 -0400 Subject: [PATCH] Add default import workaround for ESM support (#1066) * Add default import workaround for ESM support * :facepalm: * Add changeset --- .changeset/little-monkeys-build.md | 5 +++++ src/helpers/cosmiconfig.ts | 8 +++++++- 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 .changeset/little-monkeys-build.md diff --git a/.changeset/little-monkeys-build.md b/.changeset/little-monkeys-build.md new file mode 100644 index 000000000..1c5e6ba29 --- /dev/null +++ b/.changeset/little-monkeys-build.md @@ -0,0 +1,5 @@ +--- +'graphql-config': patch +--- + +Add workaround for default import of typescript config loader to fix ESM support diff --git a/src/helpers/cosmiconfig.ts b/src/helpers/cosmiconfig.ts index 8f6a85c21..5e7c6f619 100644 --- a/src/helpers/cosmiconfig.ts +++ b/src/helpers/cosmiconfig.ts @@ -1,8 +1,14 @@ import { cosmiconfig, cosmiconfigSync, Loader, defaultLoaders } from 'cosmiconfig'; -import loadTs from '@endemolshinegroup/cosmiconfig-typescript-loader'; +import loadTsPkg from '@endemolshinegroup/cosmiconfig-typescript-loader'; import { loadToml } from 'cosmiconfig-toml-loader'; import { env } from 'string-env-interpolation'; +function getDefault(module: T & { default?: T }): T { + return module.default || module; +} + +const loadTs = getDefault(loadTsPkg); + export interface ConfigSearchResult { config: any; filepath: string;