chore: import BiDi impl only if the user opts in (#9335)

This commit is contained in:
Alex Rudenko 2022-11-29 15:18:40 +01:00 committed by GitHub
parent c77b7299e2
commit e8c1d56845
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 4 deletions

View File

@ -20,7 +20,7 @@ import * as path from 'path';
import * as readline from 'readline'; import * as readline from 'readline';
import removeFolder from 'rimraf'; import removeFolder from 'rimraf';
import {promisify} from 'util'; 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 {Connection} from '../common/Connection.js';
import {debug} from '../common/Debug.js'; import {debug} from '../common/Debug.js';
import {TimeoutError} from '../common/Errors.js'; import {TimeoutError} from '../common/Errors.js';
@ -262,7 +262,8 @@ export class BrowserRunner {
); );
browserWSEndpoint += '/session'; browserWSEndpoint += '/session';
const transport = await WebSocketTransport.create(browserWSEndpoint); 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: { async setupConnection(options: {

View File

@ -2,7 +2,6 @@ import fs from 'fs';
import os from 'os'; import os from 'os';
import path from 'path'; import path from 'path';
import {Browser} from '../api/Browser.js'; import {Browser} from '../api/Browser.js';
import {Browser as BiDiBrowser} from '../common/bidi/Browser.js';
import {CDPBrowser} from '../common/Browser.js'; import {CDPBrowser} from '../common/Browser.js';
import {assert} from '../util/assert.js'; import {assert} from '../util/assert.js';
import {BrowserFetcher} from './BrowserFetcher.js'; import {BrowserFetcher} from './BrowserFetcher.js';
@ -133,7 +132,8 @@ export class FirefoxLauncher extends ProductLauncher {
slowMo, slowMo,
preferredRevision: this.puppeteer.browserRevision, preferredRevision: this.puppeteer.browserRevision,
}); });
browser = await BiDiBrowser.create({ const BiDi = await import('../common/bidi/bidi.js');
browser = await BiDi.Browser.create({
connection, connection,
closeCallback: runner.close.bind(runner), closeCallback: runner.close.bind(runner),
process: runner.proc, process: runner.proc,