Skip to content

fix(test): convert resolved paths to file:// URLs for ESM on Windows - #41137

Closed
yen0304 wants to merge 1 commit into
microsoft:mainfrom
yen0304:fix-41121
Closed

fix(test): convert resolved paths to file:// URLs for ESM on Windows#41137
yen0304 wants to merge 1 commit into
microsoft:mainfrom
yen0304:fix-41121

Conversation

@yen0304

@yen0304 yen0304 commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Summary

  • The synchronous resolve hook in esmLoaderSync.ts passes absolute paths directly to nextResolve. On Windows, paths like C:\... are parsed as having URL protocol c:, breaking ESM resolution.
  • Use context.conditions to distinguish ESM (import) from CJS (require) and convert to file:// URLs only for ESM imports.

Fixes #41121

The synchronous module hooks resolve function passes absolute paths
directly to nextResolve. On Windows, paths like "C:\..." are parsed
as having URL protocol "c:", causing ESM resolution to fail with
"Only URLs with a scheme in: file, data, and node are supported".

Use context.conditions to distinguish ESM from CJS contexts and
convert to file:// URLs only for ESM imports, preserving the absolute
path behavior for CJS require() which rejects file:// specifiers.

Fixes: microsoft#41121
@yen0304

yen0304 commented Jun 4, 2026

Copy link
Copy Markdown
Contributor Author

@microsoft-github-policy-service agree

@yen0304

yen0304 commented Jun 4, 2026

Copy link
Copy Markdown
Contributor Author

Closing in favor of #41138 by @dgozman which includes the same esmLoaderSync fix plus CI configuration updates for Windows Node 22 coverage.

@yen0304 yen0304 closed this Jun 4, 2026
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.

[Regression]: ESM projects with playwright do not work on Windows

1 participant