Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
chore: remove false await import (#40096)
Pavel Feldman4e1accb6b701
diff --git a/packages/playwright-core/src/cli/program.ts b/packages/playwright-core/src/cli/program.tsindex 17edd75b13..2c17f8cc63 100644--- a/packages/playwright-core/src/cli/program.ts+++ b/packages/playwright-core/src/cli/program.ts@@ -21,6 +21,13 @@ import { packageJSON } from '../package';import { gracefullyProcessExitDoNotHang, getPackageManagerExecCommand } from '../utils';import { addTraceCommands } from '../tools/trace/traceCli';import { program } from '../utilsBundle';+import { runDriver, runServer, printApiJson, launchBrowserServer } from './driver';+import { markDockerImage } from './installActions';+import { open, codegen } from './browserActions';+import { installBrowsers, uninstallBrowsers, installDeps } from './installActions';+import { runTraceInBrowser, runTraceViewerApp } from '../server/trace/viewer/traceViewer';+import { screenshot, pdf } from './browserActions';+import { program as cliProgram } from '../tools/cli-client/program';import type { TraceViewerServerOptions } from '../server/trace/viewer/traceViewer';import type { Command } from '../utilsBundle';@@ -36,13 +43,11 @@ export function decorateProgram(program: Command) {.description('mark docker image').allowUnknownOption(true).action(async function(dockerImageNameTemplate) {- const { markDockerImage } = await import('./installActions');markDockerImage(dockerImageNameTemplate).catch(logErrorAndExit);});commandWithOpenOptions('open [url]', 'open page in browser specified via -b, --browser', []).action(async function(url, options) {- const { open } = await import('./browserActions');open(options, url).catch(logErrorAndExit);}).addHelpText('afterAll', `@@ -57,7 +62,6 @@ export function decorateProgram(program: Command) {['--target <language>', `language to generate, one of javascript, playwright-test, python, python-async, python-pytest, csharp, csharp-mstest, csharp-nunit, java, java-junit`, codegenId()],['--test-id-attribute <attributeName>', 'use the specified attribute to generate data test ID selectors'],]).action(async function(url, options) {- const { codegen } = await import('./browserActions');await codegen(options, url);}).addHelpText('afterAll', `Examples:@@ -77,7 +81,6 @@ export function decorateProgram(program: Command) {.option('--no-shell', 'do not install chromium headless shell').action(async function(args: string[], options: { withDeps?: boolean, force?: boolean, dryRun?: boolean, list?: boolean, shell?: boolean, noShell?: boolean, onlyShell?: boolean }) {try {- const { installBrowsers } = await import('./installActions');await installBrowsers(args, options);} catch (e) {console.log(`Failed to install browsers\n${e}`);@@ -97,7 +100,6 @@ export function decorateProgram(program: Command) {.description('Removes browsers used by this installation of Playwright from the system (chromium, firefox, webkit, ffmpeg). This does not include branded channels.').option('--all', 'Removes all browsers used by any Playwright installation from the system.').action(async (options: { all?: boolean }) => {- const { uninstallBrowsers } = await import('./installActions');uninstallBrowsers(options).catch(logErrorAndExit);});@@ -107,7 +109,6 @@ export function decorateProgram(program: Command) {.option('--dry-run', 'Do not execute installation commands, only print them').action(async function(args: string[], options: { dryRun?: boolean }) {try {- const { installDeps } = await import('./installActions');await installDeps(args, options);} catch (e) {console.log(`Failed to install browser dependencies\n${e}`);@@ -130,7 +131,6 @@ export function decorateProgram(program: Command) {for (const { alias, name, type } of browsers) {commandWithOpenOptions(`${alias} [url]`, `open page in ${name}`, []).action(async function(url, options) {- const { open } = await import('./browserActions');open({ ...options, browser: type }, url).catch(logErrorAndExit);}).addHelpText('afterAll', `Examples:@@ -144,7 +144,6 @@ export function decorateProgram(program: Command) {['--wait-for-timeout <timeout>', 'wait for timeout in milliseconds before taking a screenshot'],['--full-page', 'whether to take a full page screenshot (entire scrollable area)'],]).action(async function(url, filename, command) {- const { screenshot } = await import('./browserActions');screenshot(command, command, url, filename).catch(logErrorAndExit);}).addHelpText('afterAll', `Examples:@@ -157,7 +156,6 @@ export function decorateProgram(program: Command) {['--wait-for-selector <selector>', 'wait for given selector before saving as pdf'],['--wait-for-timeout <timeout>', 'wait for given timeout in milliseconds before saving as pdf'],]).action(async function(url, filename, options) {- const { pdf } = await import('./browserActions');pdf(options, options, url, filename).catch(logErrorAndExit);}).addHelpText('afterAll', `Examples:@@ -167,7 +165,6 @@ export function decorateProgram(program: Command) {program.command('run-driver', { hidden: true }).action(async function(options) {- const { runDriver } = await import('./driver');runDriver();});@@ -180,7 +177,6 @@ export function decorateProgram(program: Command) {.option('--mode <mode>', 'Server mode, either "default" or "extension"').option('--artifacts-dir <artifactsDir>', 'Artifacts directory').action(async function(options) {- const { runServer } = await import('./driver');runServer({port: options.port ? +options.port : undefined,host: options.host,@@ -194,7 +190,6 @@ export function decorateProgram(program: Command) {program.command('print-api-json', { hidden: true }).action(async function(options) {- const { printApiJson } = await import('./driver');printApiJson();});@@ -203,7 +198,6 @@ export function decorateProgram(program: Command) {.requiredOption('--browser <browserName>', 'Browser name, one of "chromium", "firefox" or "webkit"').option('--config <path-to-config-file>', 'JSON file with launchServer options').action(async function(options) {- const { launchBrowserServer } = await import('./driver');launchBrowserServer(options.browser, options.config);});@@ -228,7 +222,6 @@ export function decorateProgram(program: Command) {isServer: !!options.stdin,};- const { runTraceInBrowser, runTraceViewerApp } = await import('../server/trace/viewer/traceViewer');if (options.port !== undefined || options.host !== undefined)runTraceInBrowser(trace, openOptions).catch(logErrorAndExit);else@@ -246,7 +239,6 @@ export function decorateProgram(program: Command) {.allowExcessArguments(true).allowUnknownOption(true).action(async options => {- const { program: cliProgram } = await import('../tools/cli-client/program');process.argv.splice(process.argv.indexOf('cli'), 1);cliProgram().catch(logErrorAndExit);});diff --git a/packages/playwright-core/src/server/bidi/bidiChromium.ts b/packages/playwright-core/src/server/bidi/bidiChromium.tsindex 4c16cc992e..2f9da8c6ef 100644--- a/packages/playwright-core/src/server/bidi/bidiChromium.ts+++ b/packages/playwright-core/src/server/bidi/bidiChromium.ts@@ -40,7 +40,7 @@ export class BidiChromium extends BrowserType {// Chrome doesn't support Bidi, we create Bidi over CDP which is used by Chrome driver.// bidiOverCdp depends on chromium-bidi which we only have in devDependencies, so// we load bidiOverCdp dynamically.- const bidiOverCdp = await import('./bidiOverCdp');+ const bidiOverCdp = require('./bidiOverCdp');const bidiTransport = await bidiOverCdp.connectBidiOverCdp(transport);(transport as any)[kBidiOverCdpWrapper] = bidiTransport;try {diff --git a/packages/playwright-core/src/server/localUtils.ts b/packages/playwright-core/src/server/localUtils.tsindex 4b8480fbf6..f6cdd4238d 100644--- a/packages/playwright-core/src/server/localUtils.ts+++ b/packages/playwright-core/src/server/localUtils.ts@@ -25,6 +25,7 @@ import { ZipFile } from './utils/zipFile';import { serializeClientSideCallMetadata } from '../utils/isomorphic/trace/traceUtils';import { assert } from '../utils/isomorphic/assert';import { removeFolders } from './utils/fileUtils';+import { yauzl, yazl } from '../zipBundle';import type * as channels from '@protocol/channels';import type * as har from '@trace/har';@@ -42,7 +43,6 @@ export type StackSession = {export async function zip(progress: Progress, stackSessions: Map<string, StackSession>, params: channels.LocalUtilsZipParams): Promise<void> {const promise = new ManualPromise<void>();- const { yauzl, yazl } = await import('../zipBundle');const zipFile = new yazl.ZipFile();(zipFile as any as EventEmitter).on('error', error => promise.reject(error));diff --git a/packages/playwright-core/src/server/recorder/recorderApp.ts b/packages/playwright-core/src/server/recorder/recorderApp.tsindex eb3fc9bafd..fda72ca039 100644--- a/packages/playwright-core/src/server/recorder/recorderApp.ts+++ b/packages/playwright-core/src/server/recorder/recorderApp.ts@@ -205,7 +205,7 @@ export class RecorderApp {const sdkLanguage = inspectedContext._browser.sdkLanguage();const isChromium = inspectedContext._browser.options.browserType === 'chromium';const headed = !!inspectedContext._browser.options.headful;- const { createPlaywright } = await import('../playwright');+ const { createPlaywright } = require('../playwright') as typeof import('../playwright');const recorderPlaywright = createPlaywright({ sdkLanguage: 'javascript', isInternalPlaywright: true });const { context: appContext, page } = await launchApp(recorderPlaywright.chromium, {sdkLanguage,diff --git a/packages/playwright-core/src/server/utils/fileUtils.ts b/packages/playwright-core/src/server/utils/fileUtils.tsindex 2b7de307b6..c6e8249e47 100644--- a/packages/playwright-core/src/server/utils/fileUtils.ts+++ b/packages/playwright-core/src/server/utils/fileUtils.ts@@ -20,6 +20,7 @@ import path from 'path';import { calculateSha1 } from './crypto';+import { yazl } from '../../zipBundle';import { ManualPromise } from '../../utils/isomorphic/manualPromise';import type { EventEmitter } from 'events';@@ -200,7 +201,6 @@ export class SerializedFS {return;}case 'zip': {- const { yazl } = await import('playwright-core/lib/zipBundle');const zipFile = new yazl.ZipFile();const result = new ManualPromise<void>();(zipFile as any as EventEmitter).on('error', error => result.reject(error));diff --git a/packages/playwright-core/src/server/utils/zipFile.ts b/packages/playwright-core/src/server/utils/zipFile.tsindex b803d6bd56..43b5a3430c 100644--- a/packages/playwright-core/src/server/utils/zipFile.ts+++ b/packages/playwright-core/src/server/utils/zipFile.ts@@ -14,6 +14,8 @@* limitations under the License.*/+import { yauzl } from '../../zipBundle';+import type { Entry, UnzipFile } from '../../zipBundle';export class ZipFile {@@ -28,7 +30,6 @@ export class ZipFile {}private async _open() {- const { yauzl } = await import('../../zipBundle');await new Promise<UnzipFile>((fulfill, reject) => {yauzl.open(this._fileName, { autoClose: false }, (e, z) => {if (e) {diff --git a/packages/playwright-core/src/tools/backend/tab.ts b/packages/playwright-core/src/tools/backend/tab.tsindex 87400f8b09..0c9ea7b37f 100644--- a/packages/playwright-core/src/tools/backend/tab.ts+++ b/packages/playwright-core/src/tools/backend/tab.ts@@ -14,8 +14,6 @@* limitations under the License.*/-import url from 'url';-import { EventEmitter } from 'events';import { asLocator } from '../../utils/isomorphic/locatorGenerators';import { locatorOrSelectorAsSelector } from '../../utils/isomorphic/locatorParser';@@ -170,7 +168,7 @@ export class Tab extends EventEmitter<TabEventsInterface> {this._requests.push(request);for (const initPage of this.context.config.browser?.initPage || []) {try {- const { default: func } = await import(url.pathToFileURL(initPage).href);+ const { default: func } = require(initPage);await func({ page: this.page });} catch (e) {debug('pw:tools:error')(e);diff --git a/packages/playwright-core/src/tools/cli-client/program.ts b/packages/playwright-core/src/tools/cli-client/program.tsindex 44ffc849da..2cc80fa22e 100644--- a/packages/playwright-core/src/tools/cli-client/program.ts+++ b/packages/playwright-core/src/tools/cli-client/program.ts@@ -238,8 +238,8 @@ async function runInitWorkspace(args: MinimistArgs) {async function installBrowser() {const argv = process.argv.map(arg => arg === 'install-browser' ? 'install' : arg);- const { libCli } = await import('../../coreBundle.js');- const { program } = await import('../../utilsBundle.js');+ const { libCli } = require('../../coreBundle.js') as typeof import('../../coreBundle');+ const { program } = require('../../utilsBundle.js') as typeof import('../../utilsBundle');if (!program.version())libCli.decorateProgram(program);program.parse(argv);diff --git a/packages/playwright-core/src/tools/trace/traceCli.ts b/packages/playwright-core/src/tools/trace/traceCli.tsindex 5bb76135c2..85cb5cc9c6 100644--- a/packages/playwright-core/src/tools/trace/traceCli.ts+++ b/packages/playwright-core/src/tools/trace/traceCli.ts@@ -14,6 +14,20 @@* limitations under the License.*/+import { traceOpen } from './traceOpen';+import { closeTrace } from './traceUtils';+import { traceActions } from './traceActions';+import { traceAction } from './traceActions';+import { traceRequests } from './traceRequests';+import { traceRequest } from './traceRequests';+import { traceConsole } from './traceConsole';+import { traceErrors } from './traceErrors';+import { traceSnapshot } from './traceSnapshot';+import { traceScreenshot } from './traceScreenshot';+import { traceAttachments } from './traceAttachments';+import { traceAttachment } from './traceAttachments';+import { installSkill } from './installSkill';+import type { Command } from '../../utilsBundle';export function addTraceCommands(program: Command, logErrorAndExit: (e: Error) => void) {@@ -25,7 +39,6 @@ export function addTraceCommands(program: Command, logErrorAndExit: (e: Error) =.command('open <trace>').description('extract trace file for inspection').action(async (trace: string) => {- const { traceOpen } = await import('./traceOpen');traceOpen(trace).catch(logErrorAndExit);});@@ -33,7 +46,6 @@ export function addTraceCommands(program: Command, logErrorAndExit: (e: Error) =.command('close').description('remove extracted trace data').action(async () => {- const { closeTrace } = await import('./traceUtils');closeTrace().catch(logErrorAndExit);});@@ -43,7 +55,6 @@ export function addTraceCommands(program: Command, logErrorAndExit: (e: Error) =.option('--grep <pattern>', 'filter actions by title pattern').option('--errors-only', 'only show failed actions').action(async (options: { grep?: string, errorsOnly?: boolean }) => {- const { traceActions } = await import('./traceActions');traceActions(options).catch(logErrorAndExit);});@@ -51,7 +62,6 @@ export function addTraceCommands(program: Command, logErrorAndExit: (e: Error) =.command('action <action-id>').description('show details of a specific action').action(async (actionId: string) => {- const { traceAction } = await import('./traceActions');traceAction(actionId).catch(logErrorAndExit);});@@ -63,7 +73,6 @@ export function addTraceCommands(program: Command, logErrorAndExit: (e: Error) =.option('--status <code>', 'filter by status code').option('--failed', 'only show failed requests (status >= 400)').action(async (options: { grep?: string, method?: string, status?: string, failed?: boolean }) => {- const { traceRequests } = await import('./traceRequests');traceRequests(options).catch(logErrorAndExit);});@@ -71,7 +80,6 @@ export function addTraceCommands(program: Command, logErrorAndExit: (e: Error) =.command('request <request-id>').description('show details of a specific network request').action(async (requestId: string) => {- const { traceRequest } = await import('./traceRequests');traceRequest(requestId).catch(logErrorAndExit);});@@ -83,7 +91,6 @@ export function addTraceCommands(program: Command, logErrorAndExit: (e: Error) =.option('--browser', 'only browser console messages').option('--stdio', 'only stdout/stderr').action(async (options: { errorsOnly?: boolean, warnings?: boolean, browser?: boolean, stdio?: boolean }) => {- const { traceConsole } = await import('./traceConsole');traceConsole(options).catch(logErrorAndExit);});@@ -91,7 +98,6 @@ export function addTraceCommands(program: Command, logErrorAndExit: (e: Error) =.command('errors').description('show errors with stack traces').action(async () => {- const { traceErrors } = await import('./traceErrors');traceErrors().catch(logErrorAndExit);});@@ -104,7 +110,6 @@ export function addTraceCommands(program: Command, logErrorAndExit: (e: Error) =.allowExcessArguments(true).action(async (actionId: string, options: { name?: string, serve?: boolean }, cmd: Command) => {try {- const { traceSnapshot } = await import('./traceSnapshot');// Collect everything after '--' as the browser command.const browserArgs = cmd.args.slice(1);await traceSnapshot(actionId, { ...options, browserArgs });@@ -118,7 +123,6 @@ export function addTraceCommands(program: Command, logErrorAndExit: (e: Error) =.description('save screencast screenshot for an action').option('-o, --output <path>', 'output file path').action(async (actionId: string, options: { output?: string }) => {- const { traceScreenshot } = await import('./traceScreenshot');traceScreenshot(actionId, options).catch(logErrorAndExit);});@@ -126,7 +130,6 @@ export function addTraceCommands(program: Command, logErrorAndExit: (e: Error) =.command('attachments').description('list trace attachments').action(async () => {- const { traceAttachments } = await import('./traceAttachments');traceAttachments().catch(logErrorAndExit);});@@ -135,7 +138,6 @@ export function addTraceCommands(program: Command, logErrorAndExit: (e: Error) =.description('extract a trace attachment by its number').option('-o, --output <path>', 'output file path').action(async (attachmentId: string, options: { output?: string }) => {- const { traceAttachment } = await import('./traceAttachments');traceAttachment(attachmentId, options).catch(logErrorAndExit);});@@ -143,7 +145,6 @@ export function addTraceCommands(program: Command, logErrorAndExit: (e: Error) =.command('install-skill').description('install SKILL.md for LLM integration').action(async () => {- const { installSkill } = await import('./installSkill');installSkill().catch(logErrorAndExit);});}diff --git a/packages/playwright/src/mcp/test/browserBackend.ts b/packages/playwright/src/mcp/test/browserBackend.tsindex a7d25045cd..b154cd391f 100644--- a/packages/playwright/src/mcp/test/browserBackend.ts+++ b/packages/playwright/src/mcp/test/browserBackend.ts@@ -42,7 +42,7 @@ export function createCustomMessageHandler(testInfo: TestInfoImpl, context: playreturn async (data: BrowserMCPRequest): Promise<BrowserMCPResponse> => {if (!tools)- ({ tools } = await import('playwright-core/lib/coreBundle'));+ ({ tools } = require('playwright-core/lib/coreBundle') as typeof import('playwright-core/lib/coreBundle'));const toolList = tools.filteredTools(config);if (data.initialize) {if (backend)diff --git a/packages/playwright/src/program.ts b/packages/playwright/src/program.tsindex 9be1485906..887e55d3cd 100644--- a/packages/playwright/src/program.ts+++ b/packages/playwright/src/program.ts@@ -18,16 +18,22 @@import 'playwright-core/lib/bootstrap';-import { libCli } from 'playwright-core/lib/coreBundle';+import { libCli, tools } from 'playwright-core/lib/coreBundle';import { program } from 'playwright-core/lib/utilsBundle';import { gracefullyProcessExitDoNotHang } from '@serverUtils/processLauncher';-import { builtInReporters, defaultReporter, defaultTimeout } from './common/config';+import { runTests } from './testActions';+import { clearCache } from './testActions';+import { startDevServer } from './testActions';+import { runTestServerAction } from './testActions';+import { showReport, mergeReports } from './reportActions';+import { TestServerBackend, testServerBackendTools } from './mcp/test/testBackend';+import { loadConfigFromFile } from './common/configLoader';+import { ClaudeGenerator, OpencodeGenerator, VSCodeGenerator, CopilotGenerator } from './agents/generateAgents';export { program };-import type { tools } from 'playwright-core/lib/coreBundle';import type { TraceMode } from '../types/test';import type { Command } from 'playwright-core/lib/utilsBundle';@@ -52,7 +58,6 @@ function addTestCommand(program: Command) {});command.action(async (args, opts) => {try {- const { runTests } = await import('./testActions');await runTests(args, opts);} catch (e) {console.error(e);@@ -75,7 +80,6 @@ function addClearCacheCommand(program: Command) {command.description('clears build and test caches');command.option('-c, --config <file>', `Configuration file, or a test directory with optional "playwright.config.{m,c}?{js,ts}"`);command.action(async opts => {- const { clearCache } = await import('./testActions');await clearCache(opts);});}@@ -85,7 +89,6 @@ function addDevServerCommand(program: Command) {command.description('start dev server');command.option('-c, --config <file>', `Configuration file, or a test directory with optional "playwright.config.{m,c}?{js,ts}"`);command.action(async options => {- const { startDevServer } = await import('./testActions');await startDevServer(options);});}@@ -97,7 +100,6 @@ function addTestServerCommand(program: Command) {command.option('--host <host>', 'Host to start the server on', 'localhost');command.option('--port <port>', 'Port to start the server on', '0');command.action(async opts => {- const { runTestServerAction } = await import('./testActions');await runTestServerAction(opts);});}@@ -106,7 +108,6 @@ function addShowReportCommand(program: Command) {const command = program.command('show-report [report]');command.description('show HTML report');command.action(async (report, options) => {- const { showReport } = await import('./reportActions');await showReport(report, options.host, +options.port);});command.option('--host <host>', 'Host to serve report on', 'localhost');@@ -125,7 +126,6 @@ function addMergeReportsCommand(program: Command) {command.description('merge multiple blob reports (for sharded tests) into a single report');command.action(async (dir, options) => {try {- const { mergeReports } = await import('./reportActions');await mergeReports(dir, options);} catch (e) {console.error(e);@@ -150,8 +150,6 @@ function addTestMCPServerCommand(program: Command) {command.option('--host <host>', 'host to bind server to. Default is localhost. Use 0.0.0.0 to bind to all interfaces.');command.option('--port <port>', 'port to listen on for SSE transport.');command.action(async options => {- const { tools } = await import('playwright-core/lib/coreBundle');- const { TestServerBackend, testServerBackendTools } = await import('./mcp/test/testBackend');tools.setupExitWatchdog();const factory: tools.ServerBackendFactory = {name: 'Playwright Test Runner',@@ -176,8 +174,6 @@ function addInitAgentsCommand(program: Command) {command.option('--project <project>', 'Project to use for seed test');command.option('--prompts', 'Whether to include prompts in the agent initialization');command.action(async opts => {- const { loadConfigFromFile } = await import('./common/configLoader');- const { ClaudeGenerator, OpencodeGenerator, VSCodeGenerator, CopilotGenerator } = await import('./agents/generateAgents');const config = await loadConfigFromFile(opts.config);if (opts.loop === 'opencode') {await OpencodeGenerator.init(config, opts.project, opts.prompts);diff --git a/packages/playwright/src/reporters/blob.ts b/packages/playwright/src/reporters/blob.tsindex a9a7f102e4..b0a5797e92 100644--- a/packages/playwright/src/reporters/blob.ts+++ b/packages/playwright/src/reporters/blob.ts@@ -19,6 +19,7 @@ import path from 'path';import { Readable } from 'stream';import { mime } from 'playwright-core/lib/utilsBundle';+import { yazl } from 'playwright-core/lib/zipBundle';import { ManualPromise } from '@isomorphic/manualPromise';import { calculateSha1, createGuid } from '@serverUtils/crypto';@@ -78,7 +79,6 @@ export class BlobReporter extends TeleReporterEmitter {const zipFileName = await this._prepareOutputFile();- const { yazl } = await import('playwright-core/lib/zipBundle');const zipFile = new yazl.ZipFile();const zipFinishPromise = new ManualPromise<undefined>();const finishPromise = zipFinishPromise.catch(e => {diff --git a/packages/playwright/src/reporters/html.ts b/packages/playwright/src/reporters/html.tsindex 69b198dbe6..3c9c8bcd80 100644--- a/packages/playwright/src/reporters/html.ts+++ b/packages/playwright/src/reporters/html.ts@@ -19,6 +19,7 @@ import path from 'path';import { Transform } from 'stream';import { colors, mime, open } from 'playwright-core/lib/utilsBundle';+import { yazl } from 'playwright-core/lib/zipBundle';import { assert } from '@isomorphic/assert';import { MultiMap } from '@isomorphic/multimap';@@ -150,7 +151,6 @@ class HtmlReporter implements ReporterV2 {const noCopyPrompt = parseBooleanEnvVar('PLAYWRIGHT_HTML_NO_COPY_PROMPT') ?? this._options.noCopyPrompt;const doNotInlineAssets = parseBooleanEnvVar('PLAYWRIGHT_HTML_DO_NOT_INLINE_ASSETS') ?? this._options.doNotInlineAssets ?? false;- const { yazl } = await import('playwright-core/lib/zipBundle');const builder = new HtmlBuilder(yazl, this.config, this._outputFolder, this._attachmentsBaseURL, doNotInlineAssets, {title: process.env.PLAYWRIGHT_HTML_TITLE || this._options.title,noSnippets,diff --git a/packages/playwright/src/worker/testTracing.ts b/packages/playwright/src/worker/testTracing.tsindex 88320d84fa..a19b955948 100644--- a/packages/playwright/src/worker/testTracing.ts+++ b/packages/playwright/src/worker/testTracing.ts@@ -17,6 +17,8 @@import fs from 'fs';import path from 'path';+import { yazl, yauzl } from 'playwright-core/lib/zipBundle';+import { ManualPromise } from '@isomorphic/manualPromise';import { monotonicTime } from '@isomorphic/time';import { calculateSha1, createGuid } from '@serverUtils/crypto';@@ -186,7 +188,6 @@ export class TestTracing {return;}- const { yazl } = await import('playwright-core/lib/zipBundle');const zipFile = new yazl.ZipFile();if (!this._options?.attachments) {@@ -351,7 +352,6 @@ async function mergeTraceFiles(fileName: string, temporaryTraceFiles: string[])}const mergePromise = new ManualPromise();- const { yazl, yauzl } = await import('playwright-core/lib/zipBundle');const zipFile = new yazl.ZipFile();const entryNames = new Set<string>();(zipFile as any as EventEmitter).on('error', error => mergePromise.reject(error));diff --git a/utils/build/build.js b/utils/build/build.jsindex 84d0785e5c..da9c2c1371 100644--- a/utils/build/build.js+++ b/utils/build/build.js@@ -474,27 +474,18 @@ const dynamicImportToRequirePlugin = {setup(build) {build.onLoad({ filter: /\.ts$/ }, async (args) => {let contents = await fs.promises.readFile(args.path, 'utf8');- const hasAwaitImport = contents.includes('await import(');const isPlaywrightSrc = args.path.includes(`${path.sep}playwright${path.sep}src${path.sep}`);const hasAlias = isPlaywrightSrc && (contents.includes("'@isomorphic/") || contents.includes("'@serverUtils/"));- if (!hasAwaitImport && !hasAlias)+ if (!hasAlias)return undefined;- if (hasAwaitImport) {- contents = contents.replace(- /\bawait import\((['"]\..*?['"])\)/g,- (_, specifier) => `require(${specifier})`- );- }- if (hasAlias) {- contents = contents.replace(- /import\s*\{([^}]*)\}\s*from\s*'@isomorphic\/[^']+';?/g,- (_, names) => `const {${names}} = require('playwright-core/lib/coreBundle').iso;`- );- contents = contents.replace(- /import\s*\{([^}]*)\}\s*from\s*'@serverUtils\/[^']+';?/g,- (_, names) => `const {${names}} = require('playwright-core/lib/coreBundle').serverUtils;`- );- }+ contents = contents.replace(+ /import\s*\{([^}]*)\}\s*from\s*'@isomorphic\/[^']+';?/g,+ (_, names) => `const {${names}} = require('playwright-core/lib/coreBundle').iso;`+ );+ contents = contents.replace(+ /import\s*\{([^}]*)\}\s*from\s*'@serverUtils\/[^']+';?/g,+ (_, names) => `const {${names}} = require('playwright-core/lib/coreBundle').serverUtils;`+ );return { contents, loader: 'ts' };});}