From e8c1d56845f747e13ce9deb927463b4e73e45302 Mon Sep 17 00:00:00 2001 From: Alex Rudenko Date: Tue, 29 Nov 2022 15:18:40 +0100 Subject: [PATCH] chore: import BiDi impl only if the user opts in (#9335) --- packages/puppeteer-core/src/node/BrowserRunner.ts | 5 +++-- packages/puppeteer-core/src/node/FirefoxLauncher.ts | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/puppeteer-core/src/node/BrowserRunner.ts b/packages/puppeteer-core/src/node/BrowserRunner.ts index 656b2842..8c1b1268 100644 --- a/packages/puppeteer-core/src/node/BrowserRunner.ts +++ b/packages/puppeteer-core/src/node/BrowserRunner.ts @@ -20,7 +20,7 @@ import * as path from 'path'; import * as readline from 'readline'; import removeFolder from 'rimraf'; import {promisify} from 'util'; -import {Connection as BiDiConnection} from '../common/bidi/Connection.js'; +import type {Connection as BiDiConnection} from '../common/bidi/bidi.js'; import {Connection} from '../common/Connection.js'; import {debug} from '../common/Debug.js'; import {TimeoutError} from '../common/Errors.js'; @@ -262,7 +262,8 @@ export class BrowserRunner { ); browserWSEndpoint += '/session'; const transport = await WebSocketTransport.create(browserWSEndpoint); - return new BiDiConnection(transport, slowMo); + const BiDi = await import('../common/bidi/bidi.js'); + return new BiDi.Connection(transport, slowMo); } async setupConnection(options: { diff --git a/packages/puppeteer-core/src/node/FirefoxLauncher.ts b/packages/puppeteer-core/src/node/FirefoxLauncher.ts index c40b77c4..f2123359 100644 --- a/packages/puppeteer-core/src/node/FirefoxLauncher.ts +++ b/packages/puppeteer-core/src/node/FirefoxLauncher.ts @@ -2,7 +2,6 @@ import fs from 'fs'; import os from 'os'; import path from 'path'; import {Browser} from '../api/Browser.js'; -import {Browser as BiDiBrowser} from '../common/bidi/Browser.js'; import {CDPBrowser} from '../common/Browser.js'; import {assert} from '../util/assert.js'; import {BrowserFetcher} from './BrowserFetcher.js'; @@ -133,7 +132,8 @@ export class FirefoxLauncher extends ProductLauncher { slowMo, preferredRevision: this.puppeteer.browserRevision, }); - browser = await BiDiBrowser.create({ + const BiDi = await import('../common/bidi/bidi.js'); + browser = await BiDi.Browser.create({ connection, closeCallback: runner.close.bind(runner), process: runner.proc,