Skip to content

Commit

Permalink
Add default import workaround for ESM support (#1066)
Browse files Browse the repository at this point in the history
* Add default import workaround for ESM support

* 🤦

* Add changeset
  • Loading branch information
ardatan authored May 24, 2022
1 parent d0d61c4 commit 44eec8d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/little-monkeys-build.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'graphql-config': patch
---

Add workaround for default import of typescript config loader to fix ESM support
8 changes: 7 additions & 1 deletion src/helpers/cosmiconfig.ts
Original file line number Diff line number Diff line change
@@ -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<T>(module: T & { default?: T }): T {
return module.default || module;
}

const loadTs = getDefault(loadTsPkg);

export interface ConfigSearchResult {
config: any;
filepath: string;
Expand Down

1 comment on commit 44eec8d

@vercel
Copy link

@vercel vercel bot commented on 44eec8d May 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.