Skip to content

Fix ESM issue for CLI require flag on Windows#10861

Merged
eddeee888 merged 4 commits into
masterfrom
fix-esm-cli-on-windows
Jun 1, 2026
Merged

Fix ESM issue for CLI require flag on Windows#10861
eddeee888 merged 4 commits into
masterfrom
fix-esm-cli-on-windows

Conversation

@eddeee888

@eddeee888 eddeee888 commented May 31, 2026

Copy link
Copy Markdown
Collaborator

Description

This PR fixes importing modules from CLI require flag for ESM on native Windows.
When the require flag is used, a module is resolved with native path e.g. C:\\Users\\path\\to\\file.ts. This is not usable in import() (dynamic import) in ESM.

To solve this for ESM, we need to use url.pathToFileURL on the filename, which converts the value with the correct protocol file:/// and path C:/Users/path/to/file.ts.
CJS works fine with import()

Related #10842

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

  • dev-test (integration)

@changeset-bot

changeset-bot Bot commented May 31, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 5312bea

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

github-actions Bot commented May 31, 2026

Copy link
Copy Markdown
Contributor

💻 Website Preview

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

@eddeee888 eddeee888 force-pushed the fix-esm-cli-on-windows branch from 29cc54f to 6683f15 Compare May 31, 2026 12:15
@eddeee888 eddeee888 force-pushed the fix-esm-cli-on-windows branch from 675991e to f797577 Compare May 31, 2026 16:29
@eddeee888 eddeee888 marked this pull request as ready for review June 1, 2026 10:40
@eddeee888 eddeee888 changed the title Fix ESM CLI on Windows Fix ESM issue for CLI require flag on Windows Jun 1, 2026
Repository owner deleted a comment from github-actions Bot Jun 1, 2026
@github-actions

github-actions Bot commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

🚀 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 7.1.2-alpha-20260601105455-5312beae60e62114e6bafbac75a47e1b2857e0dc npm ↗︎ unpkg ↗︎

@eddeee888 eddeee888 merged commit a2e1093 into master Jun 1, 2026
18 checks passed
@eddeee888 eddeee888 deleted the fix-esm-cli-on-windows branch June 1, 2026 11:08
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.

1 participant