Skip to content

Commit

Permalink
fix: top level ts-node registration bug (#8590)
Browse files Browse the repository at this point in the history
Co-authored-by: Charly POLY <1252066+charlypoly@users.noreply.github.com>
  • Loading branch information
Diizzayy and charlypoly committed Nov 30, 2022
1 parent 5abfd80 commit 2c7fa51
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/silent-singers-cover.md
@@ -0,0 +1,5 @@
---
'@graphql-codegen/cli': minor
---

register TypeScriptLoader when needed
5 changes: 2 additions & 3 deletions packages/graphql-codegen-cli/src/config.ts
Expand Up @@ -21,9 +21,6 @@ import { createHash } from 'crypto';

const { lstat } = promises;

// #8437: conflict with `graphql-config` also using TypeScriptLoader(), causing a double `ts-node` register.
const tsLoader = TypeScriptLoader({ transpileOnly: true });

export type CodegenConfig = Types.Config;

export type YamlCliFlags = {
Expand Down Expand Up @@ -77,6 +74,8 @@ function customLoader(ext: 'json' | 'yaml' | 'js' | 'ts') {
}

if (ext === 'ts') {
// #8437: conflict with `graphql-config` also using TypeScriptLoader(), causing a double `ts-node` register.
const tsLoader = TypeScriptLoader({ transpileOnly: true });
return tsLoader(filepath, content);
}
}
Expand Down

0 comments on commit 2c7fa51

Please sign in to comment.