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(build): vendor zod bundle and refactor CLI into action modules (#39883)
Pavel Feldmand665c3c99ac0
diff --git a/.claude/skills/playwright-dev/tools.md b/.claude/skills/playwright-dev/tools.mdindex 62c0e3a34e..2789feedbc 100644--- a/.claude/skills/playwright-dev/tools.md+++ b/.claude/skills/playwright-dev/tools.md@@ -9,7 +9,7 @@ Create `packages/playwright-core/src/tools/backend/<your-tool>.ts`.Import zod from the MCP bundle and use `defineTool` or `defineTabTool`:```typescript-import { z } from '../../mcpBundle';+import { z } from '../../zodBundle';import { defineTool, defineTabTool } from './tool';```@@ -201,7 +201,7 @@ Implement the corresponding MCP tool first (see section above). CLI commands calIn `packages/playwright-core/src/tools/cli-daemon/commands.ts`, use `declareCommand()`:```typescript-import { z } from '../../mcpBundle';+import { z } from '../../zodBundle';import { declareCommand } from './command';const myCommand = declareCommand({diff --git a/packages/playwright-core/ThirdPartyNotices.txt b/packages/playwright-core/ThirdPartyNotices.txtindex bdc2f1d4c1..93d7693c5a 100644--- a/packages/playwright-core/ThirdPartyNotices.txt+++ b/packages/playwright-core/ThirdPartyNotices.txt@@ -5,7 +5,7 @@ THIRD-PARTY SOFTWARE NOTICES AND INFORMATIONThis project incorporates components from the projects listed below. The original copyright notices and the licenses under which Microsoft received such components are set forth below. Microsoft reserves all rights not expressly granted herein, whether by implication, estoppel or otherwise.- @hono/[email protected] (https://github.com/honojs/node-server)-- @modelcontextprotocol/[email protected] (https://github.com/modelcontextprotocol/typescript-sdk)+- @modelcontextprotocol/[email protected] (https://github.com/modelcontextprotocol/typescript-sdk)- [email protected] (https://github.com/jshttp/accepts)- [email protected] (https://github.com/TooTallNate/proxy-agents)- [email protected] (https://github.com/ajv-validator/ajv-formats)@@ -136,7 +136,7 @@ This project incorporates components from the projects listed below. The origina- [email protected] (https://github.com/thejoshwolfe/yauzl)- [email protected] (https://github.com/thejoshwolfe/yazl)- [email protected] (https://github.com/StefanTerdell/zod-to-json-schema)-- [email protected] (https://github.com/colinhacks/zod)+- [email protected] (https://github.com/colinhacks/zod)%% @hono/[email protected] NOTICES AND INFORMATION BEGIN HERE=========================================@@ -164,7 +164,7 @@ SOFTWARE.=========================================END OF @hono/[email protected] AND INFORMATION-%% @modelcontextprotocol/[email protected] NOTICES AND INFORMATION BEGIN HERE+%% @modelcontextprotocol/[email protected] NOTICES AND INFORMATION BEGIN HERE=========================================MIT License@@ -188,7 +188,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THESOFTWARE.=========================================-END OF @modelcontextprotocol/[email protected] AND INFORMATION+END OF @modelcontextprotocol/[email protected] AND INFORMATION%% [email protected] NOTICES AND INFORMATION BEGIN HERE=========================================@@ -3519,7 +3519,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.=========================================END OF [email protected] AND INFORMATION-%% [email protected] NOTICES AND INFORMATION BEGIN HERE+%% [email protected] NOTICES AND INFORMATION BEGIN HERE=========================================MIT License@@ -3543,7 +3543,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THESOFTWARE.=========================================-END OF [email protected] AND INFORMATION+END OF [email protected] AND INFORMATIONSUMMARY BEGIN HERE=========================================diff --git a/packages/playwright-core/bundles/mcp/package-lock.json b/packages/playwright-core/bundles/mcp/package-lock.jsonindex 2e9d66dc90..6770af336d 100644--- a/packages/playwright-core/bundles/mcp/package-lock.json+++ b/packages/playwright-core/bundles/mcp/package-lock.json@@ -8,8 +8,8 @@"name": "mcp-bundle","version": "0.0.1","dependencies": {- "@modelcontextprotocol/sdk": "^1.26.0",- "zod": "^4.3.5",+ "@modelcontextprotocol/sdk": "^1.28.0",+ "zod": "^4.3.6","zod-to-json-schema": "^3.25.1"}},@@ -26,9 +26,9 @@}},"node_modules/@modelcontextprotocol/sdk": {- "version": "1.26.0",- "resolved": "https://registry.npmjs.org/@modelcontextprotocol/sdk/-/sdk-1.26.0.tgz",- "integrity": "sha512-Y5RmPncpiDtTXDbLKswIJzTqu2hyBKxTNsgKqKclDbhIgg1wgtf1fRuvxgTnRfcnxtvvgbIEcqUOzZrJ6iSReg==",+ "version": "1.28.0",+ "resolved": "https://registry.npmjs.org/@modelcontextprotocol/sdk/-/sdk-1.28.0.tgz",+ "integrity": "sha512-gmloF+i+flI8ouQK7MWW4mOwuMh4RePBuPFAEPC6+pdqyWOUMDOixb6qZ69owLJpz6XmyllCouc4t8YWO+E2Nw==","license": "MIT","dependencies": {"@hono/node-server": "^1.19.9",@@ -1115,9 +1115,10 @@"license": "ISC"},"node_modules/zod": {- "version": "4.3.5",- "resolved": "https://registry.npmjs.org/zod/-/zod-4.3.5.tgz",- "integrity": "sha512-k7Nwx6vuWx1IJ9Bjuf4Zt1PEllcwe7cls3VNzm4CQ1/hgtFUK2bRNG3rvnpPUhFjmqJKAKtjV576KnUkHocg/g==",+ "version": "4.3.6",+ "resolved": "https://registry.npmjs.org/zod/-/zod-4.3.6.tgz",+ "integrity": "sha512-rftlrkhHZOcjDwkGlnUtZZkvaPHCsDATp4pGpuOOMDaTdDDXF91wuVDJoWoPsKX/3YPQ5fHuF3STjcYyKr+Qhg==",+ "license": "MIT","funding": {"url": "https://github.com/sponsors/colinhacks"}diff --git a/packages/playwright-core/bundles/mcp/package.json b/packages/playwright-core/bundles/mcp/package.jsonindex c22e7132ef..d764e0e885 100644--- a/packages/playwright-core/bundles/mcp/package.json+++ b/packages/playwright-core/bundles/mcp/package.json@@ -3,8 +3,8 @@"version": "0.0.1","private": true,"dependencies": {- "@modelcontextprotocol/sdk": "^1.26.0",- "zod": "^4.3.5",+ "@modelcontextprotocol/sdk": "^1.28.0",+ "zod": "^4.3.6","zod-to-json-schema": "^3.25.1"}}diff --git a/packages/playwright-core/bundles/mcp/src/mcpBundleImpl.ts b/packages/playwright-core/bundles/mcp/src/mcpBundleImpl.tsindex 97a96a3c7f..d6d022be8e 100644--- a/packages/playwright-core/bundles/mcp/src/mcpBundleImpl.ts+++ b/packages/playwright-core/bundles/mcp/src/mcpBundleImpl.ts@@ -23,5 +23,4 @@ export { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'export { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';export { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js';export { CallToolRequestSchema, ListRootsRequestSchema, ListToolsRequestSchema, PingRequestSchema, ProgressNotificationSchema } from '@modelcontextprotocol/sdk/types.js';-export * as z from 'zod';export { zodToJsonSchema } from 'zod-to-json-schema';diff --git a/packages/playwright-core/bundles/zod/package-lock.json b/packages/playwright-core/bundles/zod/package-lock.jsonnew file mode 100644index 0000000000..df2577e219--- /dev/null+++ b/packages/playwright-core/bundles/zod/package-lock.json@@ -0,0 +1,24 @@+{+ "name": "zod-bundle",+ "version": "0.0.1",+ "lockfileVersion": 3,+ "requires": true,+ "packages": {+ "": {+ "name": "zod-bundle",+ "version": "0.0.1",+ "dependencies": {+ "zod": "^4.3.6"+ }+ },+ "node_modules/zod": {+ "version": "4.3.6",+ "resolved": "https://registry.npmjs.org/zod/-/zod-4.3.6.tgz",+ "integrity": "sha512-rftlrkhHZOcjDwkGlnUtZZkvaPHCsDATp4pGpuOOMDaTdDDXF91wuVDJoWoPsKX/3YPQ5fHuF3STjcYyKr+Qhg==",+ "license": "MIT",+ "funding": {+ "url": "https://github.com/sponsors/colinhacks"+ }+ }+ }+}diff --git a/packages/playwright-core/bundles/zod/package.json b/packages/playwright-core/bundles/zod/package.jsonnew file mode 100644index 0000000000..5b38cf0d9d--- /dev/null+++ b/packages/playwright-core/bundles/zod/package.json@@ -0,0 +1,8 @@+{+ "name": "zod-bundle",+ "version": "0.0.1",+ "private": true,+ "dependencies": {+ "zod": "^4.3.6"+ }+}diff --git a/packages/playwright-core/bundles/zod/src/zodBundleImpl.ts b/packages/playwright-core/bundles/zod/src/zodBundleImpl.tsnew file mode 100644index 0000000000..b95aad43e6--- /dev/null+++ b/packages/playwright-core/bundles/zod/src/zodBundleImpl.ts@@ -0,0 +1,17 @@+/**+ * Copyright (c) Microsoft Corporation.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++export * as z from 'zod';diff --git a/packages/playwright-core/package.json b/packages/playwright-core/package.jsonindex 6107faab36..be160162ee 100644--- a/packages/playwright-core/package.json+++ b/packages/playwright-core/package.json@@ -27,6 +27,7 @@"./lib/tools/cli-client/program": "./lib/tools/cli-client/program.js","./lib/tools/mcp/program": "./lib/tools/mcp/program.js","./lib/mcpBundle": "./lib/mcpBundle.js",+ "./lib/zodBundle": "./lib/zodBundle.js","./lib/tools/exports": "./lib/tools/exports.js","./lib/remote/playwrightServer": "./lib/remote/playwrightServer.js","./lib/server": "./lib/server/index.js",diff --git a/packages/playwright-core/src/client/platform.ts b/packages/playwright-core/src/client/platform.tsindex dd4fd1727e..5228e8a358 100644--- a/packages/playwright-core/src/client/platform.ts+++ b/packages/playwright-core/src/client/platform.ts@@ -59,7 +59,6 @@ export type Platform = {streamFile: (path: string, writable: Writable) => Promise<void>,streamReadable: (channel: channels.StreamChannel) => Readable,streamWritable: (channel: channels.WritableStreamChannel) => Writable,- zodToJsonSchema: (schema: any) => any,zones: { empty: Zone, current: () => Zone; };};@@ -120,9 +119,5 @@ export const emptyPlatform: Platform = {throw new Error('Streams are not available');},- zodToJsonSchema: (schema: any) => {- throw new Error('Zod is not available');- },-zones: { empty: noopZone, current: () => noopZone },};diff --git a/packages/playwright-core/src/mcpBundle.ts b/packages/playwright-core/src/mcpBundle.tsindex a9673ad6f0..501bc618ec 100644--- a/packages/playwright-core/src/mcpBundle.ts+++ b/packages/playwright-core/src/mcpBundle.ts@@ -31,7 +31,6 @@ const ListRootsRequestSchema: typeof import('@modelcontextprotocol/sdk/types.js'const ProgressNotificationSchema: typeof import('@modelcontextprotocol/sdk/types.js').ProgressNotificationSchema = bundle.ProgressNotificationSchema;const ListToolsRequestSchema: typeof import('@modelcontextprotocol/sdk/types.js').ListToolsRequestSchema = bundle.ListToolsRequestSchema;const PingRequestSchema: typeof import('@modelcontextprotocol/sdk/types.js').PingRequestSchema = bundle.PingRequestSchema;-const z: typeof import('zod') = bundle.z;export {zodToJsonSchema,@@ -48,5 +47,4 @@ export {ListToolsRequestSchema,PingRequestSchema,ProgressNotificationSchema,- z,};diff --git a/packages/playwright-core/src/server/utils/DEPS.list b/packages/playwright-core/src/server/utils/DEPS.listindex d454f3cbb8..3e42d76c2c 100644--- a/packages/playwright-core/src/server/utils/DEPS.list+++ b/packages/playwright-core/src/server/utils/DEPS.list@@ -1,5 +1,6 @@[*]../../mcpBundle.ts+../../zodBundle.ts../../utils../../utils/isomorphic../../utilsBundle.tsdiff --git a/packages/playwright-core/src/server/utils/nodePlatform.ts b/packages/playwright-core/src/server/utils/nodePlatform.tsindex 9350b5797d..84eb0e4015 100644--- a/packages/playwright-core/src/server/utils/nodePlatform.ts+++ b/packages/playwright-core/src/server/utils/nodePlatform.ts@@ -25,9 +25,6 @@ import { colors } from '../../utilsBundle';import { debugLogger } from './debugLogger';import { currentZone, emptyZone } from './zones';import { debugMode, isUnderTest } from './debug';-import { zodToJsonSchema as zodToJsonSchemaV3, z } from '../../mcpBundle';-import type zod3 from 'zod/v3';-import type zod4 from 'zod';import type { Platform, Zone } from '../../client/platform';import type { Zone as ZoneImpl } from './zones';@@ -126,13 +123,6 @@ export const nodePlatform: Platform = {return new WritableStreamImpl(channel);},- zodToJsonSchema: (schema: zod3.Schema | zod4.Schema): any => {- // https://zod.dev/library-authors?id=how-to-support-zod-3-and-zod-4-simultaneously- if ('_zod' in schema)- return z.toJSONSchema(schema);- return zodToJsonSchemaV3(schema);- },-zones: {current: () => new NodeZone(currentZone()),empty: new NodeZone(emptyZone),diff --git a/packages/playwright-core/src/tools/backend/DEPS.list b/packages/playwright-core/src/tools/backend/DEPS.listindex a2dcb1352a..84a517d68c 100644--- a/packages/playwright-core/src/tools/backend/DEPS.list+++ b/packages/playwright-core/src/tools/backend/DEPS.list@@ -1,7 +1,7 @@[*]../../..../..-../../mcpBundle.ts+../../zodBundle.ts../../server/utils/../../utils/../../utils/isomorphic/diff --git a/packages/playwright-core/src/tools/backend/common.ts b/packages/playwright-core/src/tools/backend/common.tsindex 553c072bec..8cc9dbdcc3 100644--- a/packages/playwright-core/src/tools/backend/common.ts+++ b/packages/playwright-core/src/tools/backend/common.ts@@ -14,7 +14,7 @@* limitations under the License.*/-import { z } from '../../mcpBundle';+import { z } from '../../zodBundle';import { defineTabTool, defineTool } from './tool';import { renderTabsMarkdown } from './response';diff --git a/packages/playwright-core/src/tools/backend/config.ts b/packages/playwright-core/src/tools/backend/config.tsindex 5dd862f55c..3894da55e0 100644--- a/packages/playwright-core/src/tools/backend/config.ts+++ b/packages/playwright-core/src/tools/backend/config.ts@@ -14,7 +14,7 @@* limitations under the License.*/-import { z } from '../../mcpBundle';+import { z } from '../../zodBundle';import { defineTool } from './tool';const configShow = defineTool({diff --git a/packages/playwright-core/src/tools/backend/console.ts b/packages/playwright-core/src/tools/backend/console.tsindex c2a072b130..b4158df0e4 100644--- a/packages/playwright-core/src/tools/backend/console.ts+++ b/packages/playwright-core/src/tools/backend/console.ts@@ -14,7 +14,7 @@* limitations under the License.*/-import { z } from '../../mcpBundle';+import { z } from '../../zodBundle';import { defineTabTool } from './tool';const console = defineTabTool({diff --git a/packages/playwright-core/src/tools/backend/cookies.ts b/packages/playwright-core/src/tools/backend/cookies.tsindex d0a56f97ce..fda8a8cbe2 100644--- a/packages/playwright-core/src/tools/backend/cookies.ts+++ b/packages/playwright-core/src/tools/backend/cookies.ts@@ -14,7 +14,7 @@* limitations under the License.*/-import { z } from '../../mcpBundle';+import { z } from '../../zodBundle';import { defineTool } from './tool';const cookieList = defineTool({diff --git a/packages/playwright-core/src/tools/backend/devtools.ts b/packages/playwright-core/src/tools/backend/devtools.tsindex 0db0a83664..02c3742b98 100644--- a/packages/playwright-core/src/tools/backend/devtools.ts+++ b/packages/playwright-core/src/tools/backend/devtools.ts@@ -14,7 +14,7 @@* limitations under the License.*/-import { z } from '../../mcpBundle';+import { z } from '../../zodBundle';import { defineTool } from './tool';const resume = defineTool({diff --git a/packages/playwright-core/src/tools/backend/dialogs.ts b/packages/playwright-core/src/tools/backend/dialogs.tsindex beca6dac82..23934e2156 100644--- a/packages/playwright-core/src/tools/backend/dialogs.ts+++ b/packages/playwright-core/src/tools/backend/dialogs.ts@@ -14,7 +14,7 @@* limitations under the License.*/-import { z } from '../../mcpBundle';+import { z } from '../../zodBundle';import { defineTabTool } from './tool';export const handleDialog = defineTabTool({diff --git a/packages/playwright-core/src/tools/backend/evaluate.ts b/packages/playwright-core/src/tools/backend/evaluate.tsindex 6bd02ced79..9e41bc9be4 100644--- a/packages/playwright-core/src/tools/backend/evaluate.ts+++ b/packages/playwright-core/src/tools/backend/evaluate.ts@@ -14,7 +14,7 @@* limitations under the License.*/-import { z } from '../../mcpBundle';+import { z } from '../../zodBundle';import { escapeWithQuotes } from '../../utils/isomorphic/stringUtils';import { defineTabTool } from './tool';diff --git a/packages/playwright-core/src/tools/backend/files.ts b/packages/playwright-core/src/tools/backend/files.tsindex 3a59160eb9..947da57a95 100644--- a/packages/playwright-core/src/tools/backend/files.ts+++ b/packages/playwright-core/src/tools/backend/files.ts@@ -14,7 +14,7 @@* limitations under the License.*/-import { z } from '../../mcpBundle';+import { z } from '../../zodBundle';import { defineTabTool } from './tool';export const uploadFile = defineTabTool({diff --git a/packages/playwright-core/src/tools/backend/form.ts b/packages/playwright-core/src/tools/backend/form.tsindex f9cc042bdf..ca410367d7 100644--- a/packages/playwright-core/src/tools/backend/form.ts+++ b/packages/playwright-core/src/tools/backend/form.ts@@ -14,7 +14,7 @@* limitations under the License.*/-import { z } from '../../mcpBundle';+import { z } from '../../zodBundle';import { escapeWithQuotes } from '../../utils/isomorphic/stringUtils';import { defineTabTool } from './tool';diff --git a/packages/playwright-core/src/tools/backend/keyboard.ts b/packages/playwright-core/src/tools/backend/keyboard.tsindex 7fc8b5b018..d196b9b048 100644--- a/packages/playwright-core/src/tools/backend/keyboard.ts+++ b/packages/playwright-core/src/tools/backend/keyboard.ts@@ -14,7 +14,7 @@* limitations under the License.*/-import { z } from '../../mcpBundle';+import { z } from '../../zodBundle';import { defineTabTool } from './tool';import { elementSchema } from './snapshot';diff --git a/packages/playwright-core/src/tools/backend/mouse.ts b/packages/playwright-core/src/tools/backend/mouse.tsindex bfdb29679c..f74d025cff 100644--- a/packages/playwright-core/src/tools/backend/mouse.ts+++ b/packages/playwright-core/src/tools/backend/mouse.ts@@ -14,7 +14,7 @@* limitations under the License.*/-import { z } from '../../mcpBundle';+import { z } from '../../zodBundle';import { formatObjectOrVoid } from '../../utils/isomorphic/stringUtils';import { defineTabTool } from './tool';diff --git a/packages/playwright-core/src/tools/backend/navigate.ts b/packages/playwright-core/src/tools/backend/navigate.tsindex 3e214cc425..70e5e92b28 100644--- a/packages/playwright-core/src/tools/backend/navigate.ts+++ b/packages/playwright-core/src/tools/backend/navigate.ts@@ -14,7 +14,7 @@* limitations under the License.*/-import { z } from '../../mcpBundle';+import { z } from '../../zodBundle';import { defineTool, defineTabTool } from './tool';const navigate = defineTool({diff --git a/packages/playwright-core/src/tools/backend/network.ts b/packages/playwright-core/src/tools/backend/network.tsindex 4097422b63..f0d674133d 100644--- a/packages/playwright-core/src/tools/backend/network.ts+++ b/packages/playwright-core/src/tools/backend/network.ts@@ -14,7 +14,7 @@* limitations under the License.*/-import { z } from '../../mcpBundle';+import { z } from '../../zodBundle';import { defineTool, defineTabTool } from './tool';import type * as playwright from '../../..';diff --git a/packages/playwright-core/src/tools/backend/pdf.ts b/packages/playwright-core/src/tools/backend/pdf.tsindex b6e8a37d8f..93b0291ba0 100644--- a/packages/playwright-core/src/tools/backend/pdf.ts+++ b/packages/playwright-core/src/tools/backend/pdf.ts@@ -14,7 +14,7 @@* limitations under the License.*/-import { z } from '../../mcpBundle';+import { z } from '../../zodBundle';import { formatObject } from '../../utils/isomorphic/stringUtils';import { defineTabTool } from './tool';diff --git a/packages/playwright-core/src/tools/backend/route.ts b/packages/playwright-core/src/tools/backend/route.tsindex 3b2dfb2974..de7e15f1dc 100644--- a/packages/playwright-core/src/tools/backend/route.ts+++ b/packages/playwright-core/src/tools/backend/route.ts@@ -14,7 +14,7 @@* limitations under the License.*/-import { z } from '../../mcpBundle';+import { z } from '../../zodBundle';import { defineTool } from './tool';import type * as playwright from '../../..';diff --git a/packages/playwright-core/src/tools/backend/runCode.ts b/packages/playwright-core/src/tools/backend/runCode.tsindex 0b137bc7e5..58e4f1c33c 100644--- a/packages/playwright-core/src/tools/backend/runCode.ts+++ b/packages/playwright-core/src/tools/backend/runCode.ts@@ -19,7 +19,7 @@ import vm from 'vm';import { ManualPromise } from '../../utils/isomorphic/manualPromise';-import { z } from '../../mcpBundle';+import { z } from '../../zodBundle';import { defineTabTool } from './tool';const codeSchema = z.object({diff --git a/packages/playwright-core/src/tools/backend/screenshot.ts b/packages/playwright-core/src/tools/backend/screenshot.tsindex 4cfa23e760..8031e53903 100644--- a/packages/playwright-core/src/tools/backend/screenshot.ts+++ b/packages/playwright-core/src/tools/backend/screenshot.ts@@ -18,7 +18,7 @@ import { scaleImageToSize } from '../../utils/isomorphic/imageUtils';import { jpegjs, PNG } from '../../utilsBundle';import { formatObject } from '../../utils/isomorphic/stringUtils';-import { z } from '../../mcpBundle';+import { z } from '../../zodBundle';import { defineTabTool } from './tool';import type * as playwright from '../../..';diff --git a/packages/playwright-core/src/tools/backend/snapshot.ts b/packages/playwright-core/src/tools/backend/snapshot.tsindex 2fced17c98..75ae63f1cf 100644--- a/packages/playwright-core/src/tools/backend/snapshot.ts+++ b/packages/playwright-core/src/tools/backend/snapshot.ts@@ -14,7 +14,7 @@* limitations under the License.*/-import { z } from '../../mcpBundle';+import { z } from '../../zodBundle';import { formatObject, formatObjectOrVoid } from '../../utils/isomorphic/stringUtils';import { defineTabTool, defineTool } from './tool';diff --git a/packages/playwright-core/src/tools/backend/storage.ts b/packages/playwright-core/src/tools/backend/storage.tsindex 152ba453b1..d55148c296 100644--- a/packages/playwright-core/src/tools/backend/storage.ts+++ b/packages/playwright-core/src/tools/backend/storage.ts@@ -14,7 +14,7 @@* limitations under the License.*/-import { z } from '../../mcpBundle';+import { z } from '../../zodBundle';import { defineTool } from './tool';const storageState = defineTool({diff --git a/packages/playwright-core/src/tools/backend/tabs.ts b/packages/playwright-core/src/tools/backend/tabs.tsindex 679421be3f..0fcd98dbf7 100644--- a/packages/playwright-core/src/tools/backend/tabs.ts+++ b/packages/playwright-core/src/tools/backend/tabs.ts@@ -14,7 +14,7 @@* limitations under the License.*/-import { z } from '../../mcpBundle';+import { z } from '../../zodBundle';import { defineTool } from './tool';import { renderTabsMarkdown } from './response';diff --git a/packages/playwright-core/src/tools/backend/tools.ts b/packages/playwright-core/src/tools/backend/tools.tsindex de8d3eda86..9cb7a63b6e 100644--- a/packages/playwright-core/src/tools/backend/tools.ts+++ b/packages/playwright-core/src/tools/backend/tools.ts@@ -14,7 +14,7 @@* limitations under the License.*/-import { z } from '../../mcpBundle';+import { z } from '../../zodBundle';import common from './common';import config from './config';diff --git a/packages/playwright-core/src/tools/backend/tracing.ts b/packages/playwright-core/src/tools/backend/tracing.tsindex 2d8090c0d4..f042d93ff5 100644--- a/packages/playwright-core/src/tools/backend/tracing.ts+++ b/packages/playwright-core/src/tools/backend/tracing.ts@@ -14,7 +14,7 @@* limitations under the License.*/-import { z } from '../../mcpBundle';+import { z } from '../../zodBundle';import { defineTool } from './tool';diff --git a/packages/playwright-core/src/tools/backend/verify.ts b/packages/playwright-core/src/tools/backend/verify.tsindex 48f012216c..821018a18c 100644--- a/packages/playwright-core/src/tools/backend/verify.ts+++ b/packages/playwright-core/src/tools/backend/verify.ts@@ -14,7 +14,7 @@* limitations under the License.*/-import { z } from '../../mcpBundle';+import { z } from '../../zodBundle';import { escapeWithQuotes } from '../../utils/isomorphic/stringUtils';import { defineTabTool } from './tool';diff --git a/packages/playwright-core/src/tools/backend/video.ts b/packages/playwright-core/src/tools/backend/video.tsindex 8b1d1f93c0..432be49c25 100644--- a/packages/playwright-core/src/tools/backend/video.ts+++ b/packages/playwright-core/src/tools/backend/video.ts@@ -15,7 +15,7 @@*/import path from 'path';-import { z } from '../../mcpBundle';+import { z } from '../../zodBundle';import { defineTool } from './tool';const startVideo = defineTool({diff --git a/packages/playwright-core/src/tools/backend/wait.ts b/packages/playwright-core/src/tools/backend/wait.tsindex 6de520941b..6b8c4b03c9 100644--- a/packages/playwright-core/src/tools/backend/wait.ts+++ b/packages/playwright-core/src/tools/backend/wait.ts@@ -14,7 +14,7 @@* limitations under the License.*/-import { z } from '../../mcpBundle';+import { z } from '../../zodBundle';import { defineTool } from './tool';const wait = defineTool({diff --git a/packages/playwright-core/src/tools/backend/webstorage.ts b/packages/playwright-core/src/tools/backend/webstorage.tsindex 8c2598a444..0c11e2129a 100644--- a/packages/playwright-core/src/tools/backend/webstorage.ts+++ b/packages/playwright-core/src/tools/backend/webstorage.ts@@ -14,7 +14,7 @@* limitations under the License.*/-import { z } from '../../mcpBundle';+import { z } from '../../zodBundle';import { defineTabTool } from './tool';const localStorageList = defineTabTool({diff --git a/packages/playwright-core/src/tools/cli-daemon/DEPS.list b/packages/playwright-core/src/tools/cli-daemon/DEPS.listindex da410b83b2..23a1384c5c 100644--- a/packages/playwright-core/src/tools/cli-daemon/DEPS.list+++ b/packages/playwright-core/src/tools/cli-daemon/DEPS.list@@ -5,6 +5,6 @@../mcp/../../utilsBundle.ts../../utils/-../../mcpBundle.ts+../../zodBundle.ts../../server/utils/../../serverRegistry.tsdiff --git a/packages/playwright-core/src/tools/cli-daemon/command.ts b/packages/playwright-core/src/tools/cli-daemon/command.tsindex bd60bf7bf7..faf5aa838b 100644--- a/packages/playwright-core/src/tools/cli-daemon/command.ts+++ b/packages/playwright-core/src/tools/cli-daemon/command.ts@@ -14,7 +14,7 @@* limitations under the License.*/-import { z } from '../../mcpBundle';+import { z } from '../../zodBundle';import type zodType from 'zod';diff --git a/packages/playwright-core/src/tools/cli-daemon/commands.ts b/packages/playwright-core/src/tools/cli-daemon/commands.tsindex e82d673d9d..b9f3398c01 100644--- a/packages/playwright-core/src/tools/cli-daemon/commands.ts+++ b/packages/playwright-core/src/tools/cli-daemon/commands.ts@@ -14,7 +14,7 @@* limitations under the License.*/-import { z } from '../../mcpBundle';+import { z } from '../../zodBundle';import { declareCommand } from './command';import type { AnyCommandSchema } from './command';diff --git a/packages/playwright-core/src/tools/cli-daemon/helpGenerator.ts b/packages/playwright-core/src/tools/cli-daemon/helpGenerator.tsindex 4946986579..aed0ddacd1 100644--- a/packages/playwright-core/src/tools/cli-daemon/helpGenerator.ts+++ b/packages/playwright-core/src/tools/cli-daemon/helpGenerator.ts@@ -14,7 +14,7 @@* limitations under the License.*/-import { z } from '../../mcpBundle';+import { z } from '../../zodBundle';import { commands } from './commands';diff --git a/packages/playwright-core/src/tools/utils/mcp/DEPS.list b/packages/playwright-core/src/tools/utils/mcp/DEPS.listindex 9f67c501dd..2b5fc59b8a 100644--- a/packages/playwright-core/src/tools/utils/mcp/DEPS.list+++ b/packages/playwright-core/src/tools/utils/mcp/DEPS.list@@ -1,4 +1,5 @@[*]../../../mcpBundle.ts+../../../zodBundle.ts../../../utilsBundle.ts../../../server/utils/network.tsdiff --git a/packages/playwright-core/src/tools/utils/mcp/tool.ts b/packages/playwright-core/src/tools/utils/mcp/tool.tsindex 465ad8ddea..a2b8866127 100644--- a/packages/playwright-core/src/tools/utils/mcp/tool.ts+++ b/packages/playwright-core/src/tools/utils/mcp/tool.ts@@ -14,7 +14,7 @@* limitations under the License.*/-import { z as zod } from '../../../mcpBundle';+import { z as zod } from '../../../zodBundle';import type { z } from 'zod';import type * as mcpServer from './server';diff --git a/packages/playwright-core/src/zodBundle.ts b/packages/playwright-core/src/zodBundle.tsnew file mode 100644index 0000000000..e2dbe76193--- /dev/null+++ b/packages/playwright-core/src/zodBundle.ts@@ -0,0 +1,24 @@+/**+ * Copyright (c) Microsoft Corporation.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++// @ts-ignore+import * as bundle from './zodBundleImpl';++const z: typeof import('zod') = bundle.z;++export {+ z,+};diff --git a/packages/playwright/src/common/validators.ts b/packages/playwright/src/common/validators.tsindex 1bb2df5758..40fff8b365 100644--- a/packages/playwright/src/common/validators.ts+++ b/packages/playwright/src/common/validators.ts@@ -14,7 +14,7 @@* limitations under the License.*/-import { z as zod } from 'playwright-core/lib/mcpBundle';+import { z as zod } from 'playwright-core/lib/zodBundle';import type { TestAnnotation, TestDetailsAnnotation } from '../../types/test';import type { Location } from '../../types/testReporter';diff --git a/packages/playwright/src/mcp/test/generatorTools.ts b/packages/playwright/src/mcp/test/generatorTools.tsindex 13cfbd1af6..15932fc756 100644--- a/packages/playwright/src/mcp/test/generatorTools.ts+++ b/packages/playwright/src/mcp/test/generatorTools.ts@@ -17,7 +17,7 @@import fs from 'fs';import path from 'path';-import { z } from 'playwright-core/lib/mcpBundle';+import { z } from 'playwright-core/lib/zodBundle';import { defineTestTool } from './testTool';import { GeneratorJournal } from './testContext';diff --git a/packages/playwright/src/mcp/test/plannerTools.ts b/packages/playwright/src/mcp/test/plannerTools.tsindex 1dad8af004..2c725691b9 100644--- a/packages/playwright/src/mcp/test/plannerTools.ts+++ b/packages/playwright/src/mcp/test/plannerTools.ts@@ -17,7 +17,7 @@import fs from 'fs';import path from 'path';-import { z } from 'playwright-core/lib/mcpBundle';+import { z } from 'playwright-core/lib/zodBundle';import { defineTestTool } from './testTool';export const setupPage = defineTestTool({diff --git a/packages/playwright/src/mcp/test/testBackend.ts b/packages/playwright/src/mcp/test/testBackend.tsindex f371ee4ed5..d554068f02 100644--- a/packages/playwright/src/mcp/test/testBackend.ts+++ b/packages/playwright/src/mcp/test/testBackend.ts@@ -16,7 +16,7 @@import EventEmitter from 'events';-import { z as zod } from 'playwright-core/lib/mcpBundle';+import { z as zod } from 'playwright-core/lib/zodBundle';import * as mcp from 'playwright-core/lib/tools/exports';import { browserTools } from 'playwright-core/lib/tools/exports';diff --git a/packages/playwright/src/mcp/test/testTools.ts b/packages/playwright/src/mcp/test/testTools.tsindex 0382bc9cce..eb7c9f7f6c 100644--- a/packages/playwright/src/mcp/test/testTools.ts+++ b/packages/playwright/src/mcp/test/testTools.ts@@ -14,7 +14,7 @@* limitations under the License.*/-import { z } from 'playwright-core/lib/mcpBundle';+import { z } from 'playwright-core/lib/zodBundle';import ListModeReporter from '../../reporters/listModeReporter';import { defineTestTool } from './testTool';diff --git a/utils/build/build.js b/utils/build/build.jsindex 147c8eca04..70ace25544 100644--- a/utils/build/build.js+++ b/utils/build/build.js@@ -69,6 +69,8 @@ const copyFiles = [];const watchMode = process.argv.slice(2).includes('--watch');const withSourceMaps = watchMode;const disableInstall = process.argv.slice(2).includes('--disable-install');+const bundleFilterIndex = process.argv.indexOf('--bundle');+const bundleFilter = bundleFilterIndex !== -1 ? process.argv[bundleFilterIndex + 1] : undefined;const ROOT = path.join(__dirname, '..', '..');/**@@ -200,6 +202,19 @@ async function runWatch() {runOnChange(onChange);}+/**+ * @param {string} filter+ */+async function runBundleOnly(filter) {+ const matching = bundleSteps.filter((_, i) => bundles[i].modulePath.includes(filter));+ if (!matching.length) {+ console.error(`No bundles matching "${filter}". Available: ${bundles.map(b => b.modulePath).join(', ')}`);+ process.exit(1);+ }+ for (const step of matching)+ await step.run();+}+async function runBuild() {for (const { files, from, to, ignored } of copyFiles) {const watcher = chokidar.watch([filePath(files)], {@@ -277,7 +292,7 @@ bundles.push({bundles.push({modulePath: 'packages/playwright-core/bundles/mcp',- outfile: 'packages/playwright-core/lib/mcpBundleImpl/index.js',+ outfile: 'packages/playwright-core/lib/mcpBundleImpl.js',entryPoints: ['src/mcpBundleImpl.ts'],external: ['express', '@anthropic-ai/sdk'],alias: {@@ -285,6 +300,12 @@ bundles.push({},});+bundles.push({+ modulePath: 'packages/playwright-core/bundles/zod',+ outfile: 'packages/playwright-core/lib/zodBundleImpl.js',+ entryPoints: ['src/zodBundleImpl.ts'],+});+// @playwright/clientbundles.push({modulePath: 'packages/playwright-client',@@ -518,9 +539,12 @@ const pkgSizePlugin = {};// Build/watch bundles.-for (const bundle of bundles) {- /** @type {import('esbuild').BuildOptions} */- const options = {+/**+ * @param {BundleOptions} bundle+ * @returns {import('esbuild').BuildOptions}+ */+function bundleToEsbuildOptions(bundle) {+ return {bundle: true,format: 'cjs',platform: 'node',@@ -537,9 +561,13 @@ for (const bundle of bundles) {metafile: true,plugins: [pkgSizePlugin],};- steps.push(new EsbuildStep(options));}+/** @type {EsbuildStep[]} */+const bundleSteps = bundles.map(b => new EsbuildStep(bundleToEsbuildOptions(b)));+for (const step of bundleSteps)+ steps.push(step);+// Build/watch trace viewer service worker.steps.push(new ProgramStep({command: 'npx',@@ -717,4 +745,4 @@ process.on('SIGINT', () => {});-watchMode ? runWatch() : runBuild();+bundleFilter ? runBundleOnly(bundleFilter) : watchMode ? runWatch() : runBuild();