fix(browser): load Playwright runtime on demand (#127049)

* fix(browser): load Playwright runtime on demand

* test(browser): use lazy Playwright accessor

* fix(worker): bind bundled Playwright runtime

* style(worker): format build regression

* style(worker): apply repository formatter
This commit is contained in:
Dallin Romney
2026-08-21 10:45:18 -07:00
committed by GitHub
parent b9dda9d740
commit 8dd21b0f34
10 changed files with 60 additions and 32 deletions
@@ -35,6 +35,20 @@ describe("worker deploy build plugin", () => {
expect(transformed).not.toContain("was not composed by the build");
});
it("binds the lazy Playwright accessor to bundled modules", () => {
const runtimePath = path.resolve("extensions/browser/src/browser/playwright-core.runtime.ts");
const source = fs.readFileSync(runtimePath, "utf8");
const plugin = createWorkerDeployBuildPlugin();
const transformed = plugin.transform.call({ error: fail }, source, runtimePath);
expect(transformed).toContain('import * as playwrightCore from "playwright-core";');
expect(transformed).toContain('import { getUserAgent } from "playwright-core/lib/coreBundle";');
expect(transformed).toContain("return playwrightCore;");
expect(transformed).not.toContain("createRequire");
expect(transformed).not.toContain('require("playwright-core")');
});
it("bundles the undici dispatcher dependency without a worker runtime require", () => {
const dispatcherPath = path.resolve("src/infra/net/undici-dispatcher-options.ts");
const source = fs.readFileSync(dispatcherPath, "utf8");