Skip to content

fix(test): load require-reached files as commonjs in sync ESM loader#41399

Merged
dgozman merged 1 commit into
microsoft:mainfrom
dgozman:fix-41371
Jun 22, 2026
Merged

fix(test): load require-reached files as commonjs in sync ESM loader#41399
dgozman merged 1 commit into
microsoft:mainfrom
dgozman:fix-41371

Conversation

@dgozman

@dgozman dgozman commented Jun 21, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • The synchronous ESM loader loaded type: module files reached via require as real ESM, so their bare/subpath specifiers fell through to Node's native ESM resolver, which never tries the .ts extension. This broke extensionless TypeScript subpath imports across workspace (pnpm) symlinks — a regression from the async loader.
  • Fix: load files reached under the require condition as CommonJS (read from context.conditions in the load hook), matching the async loader, so TypeScript extension substitution applies to their child specifiers.

Fixes #41371

The synchronous ESM loader loaded `type: module` files reached via
`require` as real ESM. Their bare/subpath specifiers then fell through to
Node's native ESM resolver, which never tries the `.ts` extension, so
extensionless TypeScript subpath imports across workspace symlinks failed.

Load files reached under the `require` condition as CommonJS instead,
matching the asynchronous loader, so TypeScript extension substitution
applies to their child specifiers.

Fixes: microsoft#41371
@github-actions

Copy link
Copy Markdown
Contributor

Test results for "MCP"

1 failed
❌ [chrome] › mcp/annotate.spec.ts:57 › should capture multiple screenshots in one annotation @mcp-ubuntu-latest-chrome

7353 passed, 1122 skipped


Merge workflow run.

@github-actions

Copy link
Copy Markdown
Contributor

Test results for "tests 1"

1 failed
❌ [firefox-page] › page/workers.spec.ts:40 › should emit created and destroyed events @firefox-ubuntu-22.04-node20

5 flaky ⚠️ [chromium-library] › library/video.spec.ts:717 › screencast › should work with video+trace `@chromium-ubuntu-22.04-arm-node20`
⚠️ [chromium-library] › library/chromium/chromium.spec.ts:371 › should produce network events, routing, and annotations for Service Worker `@chromium-ubuntu-22.04-node24`
⚠️ [firefox-library] › library/browsertype-launch.spec.ts:122 › should allow await using `@firefox-ubuntu-22.04-node20`
⚠️ [firefox-library] › library/firefox/launcher.spec.ts:48 › should support custom firefox policies `@firefox-ubuntu-22.04-node20`
⚠️ [playwright-test] › ui-mode-test-update.spec.ts:202 › should update test locations `@ubuntu-latest-node26`

48912 passed, 1142 skipped


Merge workflow run.

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]: Sync ESM loader (registerHooks) fails to resolve extensionless .ts subpath imports across pnpm workspace symlinks

2 participants