Chrome DevTools for coding agents
refactor: re-export only used Zod runtime members from third_party barrel (#3439)
Nikolay Vitkov6b056c848a98
diff --git a/src/BUILD.gn b/src/BUILD.gnindex 51dc2cf4..f3587224 100644--- a/src/BUILD.gn+++ b/src/BUILD.gn@@ -37,6 +37,7 @@ ts_library("third_party") {"third_party/devtools-heap-snapshot-worker.ts","third_party/index.ts","third_party/lighthouse-devtools-mcp-bundle.d.ts",+ "third_party/zod.ts",]ts_deps = [diff --git a/src/third_party/index.ts b/src/third_party/index.tsindex 1b717810..636efe62 100644--- a/src/third_party/index.ts+++ b/src/third_party/index.ts@@ -10,12 +10,12 @@ import 'core-js/proposals/iterator-helpers.js';import type {Flags, OutputMode, Result, RunnerResult} from 'lighthouse';import type {Page} from 'puppeteer-core';-import {z as zod} from 'zod';// eslint-disable-next-line no-restricted-importsimport * as DevToolsRoot from '../../third_party/devtools-frontend/front_end/core/root/root.js';import type * as LighthouseBundle from './lighthouse-devtools-mcp-bundle.js';+import * as zod from './zod.js';export type {Flags, Result, RunnerResult, OutputMode};diff --git a/src/third_party/zod.ts b/src/third_party/zod.tsnew file mode 100644index 00000000..c985f086--- /dev/null+++ b/src/third_party/zod.ts@@ -0,0 +1,23 @@+/**+ * @license+ * Copyright 2026 Google LLC+ * SPDX-License-Identifier: Apache-2.0+ */++// Export all Zod types, but only the runtime values used in this repository so+// that bundlers tree-shake unused exports (such as the 64 locale tables).+export type * from 'zod';+export {+ array,+ boolean,+ coerce,+ enum,+ NEVER,+ number,+ object,+ record,+ string,+ toJSONSchema,+ unknown,+ ZodError,+} from 'zod';diff --git a/tests/cli-imports.test.ts b/tests/cli-imports.test.tsindex 2b6e9482..3187a520 100644--- a/tests/cli-imports.test.ts+++ b/tests/cli-imports.test.ts@@ -9,6 +9,8 @@ import {readFileSync} from 'node:fs';import path from 'node:path';import {describe, it} from 'node:test';+import {zod} from '../src/third_party/index.js';+const BUILD_SRC = path.resolve(import.meta.dirname, '..', 'src');const CLI_ENTRY = path.join(BUILD_SRC, 'bin', 'chrome-devtools.js');const FULL_BUNDLE = path.join(BUILD_SRC, 'third_party', 'index.js');@@ -58,4 +60,8 @@ describe('chrome-devtools CLI imports', () => {`The CLI must import from third_party/cli.js only. Import chain:\n ${chain?.join('\n -> ')}`,);});++ it('does not re-export unused zod locales from the third-party barrel', () => {+ assert.strictEqual('locales' in zod, false);+ });});