Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

Skip ESM loader registration in `bun` (to avoid a hang). (#38599)

Lucas Garrona97216295e1e
diff --git a/packages/playwright/src/common/esmLoaderHost.ts b/packages/playwright/src/common/esmLoaderHost.ts
index 6a44c24166..456def7bb0 100644
--- a/packages/playwright/src/common/esmLoaderHost.ts
+++ b/packages/playwright/src/common/esmLoaderHost.ts
@@ -27,6 +27,11 @@ export function registerESMLoader() {
if (process.env.PW_DISABLE_TS_ESM)
return true;
+ // Transpilation in `bun` is not necessary, and trying to register a hook would cause issues.
+ // https://github.com/oven-sh/bun/issues/8222#issuecomment-3665364677
+ if ('Bun' in globalThis)
+ return true;
+
if (loaderChannel)
return true;