Skip to content

feat(cli): use ESM by default#10705

Open
ardatan wants to merge 2 commits intomasterfrom
esm-cli
Open

feat(cli): use ESM by default#10705
ardatan wants to merge 2 commits intomasterfrom
esm-cli

Conversation

@ardatan
Copy link
Copy Markdown
Collaborator

@ardatan ardatan commented Apr 10, 2026

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

@ardatan ardatan requested review from Copilot and eddeee888 April 10, 2026 10:43
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 10, 2026

🦋 Changeset detected

Latest commit: 4515fe5

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@graphql-codegen/cli Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 10, 2026

🚀 Snapshot Release (alpha)

The latest changes of this PR are available as alpha on npm (based on the declared changesets):

Package Version Info
@graphql-codegen/cli 6.2.2-alpha-20260410105346-4515fe5a1ccdbb24814e98ecc94c627d826c2d3a npm ↗︎ unpkg ↗︎
@graphql-codegen/core 5.0.2-alpha-20260410105346-4515fe5a1ccdbb24814e98ecc94c627d826c2d3a npm ↗︎ unpkg ↗︎
@graphql-codegen/add 6.0.1-alpha-20260410105346-4515fe5a1ccdbb24814e98ecc94c627d826c2d3a npm ↗︎ unpkg ↗︎
@graphql-codegen/fragment-matcher 6.0.1-alpha-20260410105346-4515fe5a1ccdbb24814e98ecc94c627d826c2d3a npm ↗︎ unpkg ↗︎
@graphql-codegen/introspection 5.0.2-alpha-20260410105346-4515fe5a1ccdbb24814e98ecc94c627d826c2d3a npm ↗︎ unpkg ↗︎
@graphql-codegen/schema-ast 5.0.2-alpha-20260410105346-4515fe5a1ccdbb24814e98ecc94c627d826c2d3a npm ↗︎ unpkg ↗︎
@graphql-codegen/visitor-plugin-common 6.2.5-alpha-20260410105346-4515fe5a1ccdbb24814e98ecc94c627d826c2d3a npm ↗︎ unpkg ↗︎
@graphql-codegen/typescript-document-nodes 5.0.10-alpha-20260410105346-4515fe5a1ccdbb24814e98ecc94c627d826c2d3a npm ↗︎ unpkg ↗︎
@graphql-codegen/gql-tag-operations 5.1.5-alpha-20260410105346-4515fe5a1ccdbb24814e98ecc94c627d826c2d3a npm ↗︎ unpkg ↗︎
@graphql-codegen/typescript-operations 5.0.10-alpha-20260410105346-4515fe5a1ccdbb24814e98ecc94c627d826c2d3a npm ↗︎ unpkg ↗︎
@graphql-codegen/typescript-resolvers 5.1.8-alpha-20260410105346-4515fe5a1ccdbb24814e98ecc94c627d826c2d3a npm ↗︎ unpkg ↗︎
@graphql-codegen/typed-document-node 6.1.8-alpha-20260410105346-4515fe5a1ccdbb24814e98ecc94c627d826c2d3a npm ↗︎ unpkg ↗︎
@graphql-codegen/typescript 5.0.10-alpha-20260410105346-4515fe5a1ccdbb24814e98ecc94c627d826c2d3a npm ↗︎ unpkg ↗︎
@graphql-codegen/client-preset 5.2.5-alpha-20260410105346-4515fe5a1ccdbb24814e98ecc94c627d826c2d3a npm ↗︎ unpkg ↗︎
@graphql-codegen/graphql-modules-preset 5.1.5-alpha-20260410105346-4515fe5a1ccdbb24814e98ecc94c627d826c2d3a npm ↗︎ unpkg ↗︎
@graphql-codegen/testing 4.0.5-alpha-20260410105346-4515fe5a1ccdbb24814e98ecc94c627d826c2d3a npm ↗︎ unpkg ↗︎
@graphql-codegen/plugin-helpers 6.2.2-alpha-20260410105346-4515fe5a1ccdbb24814e98ecc94c627d826c2d3a npm ↗︎ unpkg ↗︎

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Switches the @graphql-codegen/cli default executable entrypoint to ESM while adding/retaining alternative command names for compatibility.

Changes:

  • Update bin mappings so graphql-codegen/gql-gen/graphql-code-generator run the ESM build by default.
  • Add a dedicated graphql-codegen-cjs command and document the intended command matrix via a changeset.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
packages/graphql-codegen-cli/package.json Updates CLI binary entrypoints to prefer ESM and introduces a CJS-specific alias.
.changeset/wacky-books-post.md Release note describing the new default (ESM) and available CLI commands.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 10, 2026

💻 Website Preview

The latest changes are available as preview in: https://pr-10705.graphql-code-generator.pages.dev

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants