From 2d95ae6d67c1e8bc56f295b381c59c7bc83103b7 Mon Sep 17 00:00:00 2001 From: Arda TANRIKULU Date: Fri, 10 Apr 2026 13:43:33 +0300 Subject: [PATCH 1/2] feat(cli): use `ESM` by default --- .changeset/wacky-books-post.md | 14 ++++++++++++++ packages/graphql-codegen-cli/package.json | 9 +++++---- 2 files changed, 19 insertions(+), 4 deletions(-) create mode 100644 .changeset/wacky-books-post.md diff --git a/.changeset/wacky-books-post.md b/.changeset/wacky-books-post.md new file mode 100644 index 00000000000..47fca5fee43 --- /dev/null +++ b/.changeset/wacky-books-post.md @@ -0,0 +1,14 @@ +--- +'@graphql-codegen/cli': patch +--- + +Use ESM for CLI instead of CJS; + +For backwards compatibility; `graphql-codegen-esm` is reserved, and also `graphql-codegen-cjs` is added for users who want to use CJS. + +So the commands are; +- `graphql-codegen` - ESM version, default +- `graphql-codegen-esm` - ESM version, same as above, but reserved for backwards compatibility +- `graphql-codegen-cjs` - CJS version, for users who want to use CJS, but not recommended for new users. Will be removed in the future. +- `gql-gen` - ESM version, same as `graphql-codegen` +- `graphql-code-generator` - ESM version, same as `graphql-codegen` and `gql-gen` diff --git a/packages/graphql-codegen-cli/package.json b/packages/graphql-codegen-cli/package.json index 72fa79180dc..c9fe335012b 100644 --- a/packages/graphql-codegen-cli/package.json +++ b/packages/graphql-codegen-cli/package.json @@ -17,10 +17,11 @@ "node": ">=16" }, "bin": { - "gql-gen": "dist/cjs/bin.js", - "graphql-codegen": "dist/cjs/bin.js", - "graphql-code-generator": "dist/cjs/bin.js", - "graphql-codegen-esm": "dist/esm/bin.js" + "gql-gen": "dist/esm/bin.js", + "graphql-codegen": "dist/esm/bin.js", + "graphql-code-generator": "dist/esm/bin.js", + "graphql-codegen-esm": "dist/cjs/bin.js", + "graphql-codegen-cjs": "dist/cjs/bin.js" }, "main": "dist/cjs/index.js", "module": "dist/esm/index.js", From 4515fe5a1ccdbb24814e98ecc94c627d826c2d3a Mon Sep 17 00:00:00 2001 From: Arda TANRIKULU Date: Fri, 10 Apr 2026 13:52:09 +0300 Subject: [PATCH 2/2] Update graphql-codegen-esm to use esm/bin.js --- packages/graphql-codegen-cli/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/graphql-codegen-cli/package.json b/packages/graphql-codegen-cli/package.json index c9fe335012b..f36e8f1b007 100644 --- a/packages/graphql-codegen-cli/package.json +++ b/packages/graphql-codegen-cli/package.json @@ -20,7 +20,7 @@ "gql-gen": "dist/esm/bin.js", "graphql-codegen": "dist/esm/bin.js", "graphql-code-generator": "dist/esm/bin.js", - "graphql-codegen-esm": "dist/cjs/bin.js", + "graphql-codegen-esm": "dist/esm/bin.js", "graphql-codegen-cjs": "dist/cjs/bin.js" }, "main": "dist/cjs/index.js",