Chrome DevTools for coding agents
build: migrate third_party TS compilation and assets to src/BUILD.gn (#3330)
Nikolay Vitkov98c4dbc1e113
diff --git a/BUILD.gn b/BUILD.gnindex fb8c9a68..2880a840 100644--- a/BUILD.gn+++ b/BUILD.gn@@ -1,15 +1,23 @@# Copyright 2026 Google LLC# SPDX-License-Identifier: Apache-2.0-group("devtools_deps") {+group("default") {deps = [+ ":devtools_deps",+ "//src:issue_descriptions",+ "//src:lighthouse_bundle",+ "//src:third_party",+ ]+}++group("devtools_deps") {+ public_deps = [+ "//src:issue_descriptions",+ "//src:lighthouse_bundle",+ "//src:third_party","//third_party/devtools-frontend/front_end/entrypoints/formatter_worker:worker_entrypoint","//third_party/devtools-frontend/front_end/entrypoints/heap_snapshot_worker:worker_entrypoint","//third_party/devtools-frontend/front_end/models/issues_manager:descriptions",- "//third_party/devtools-frontend/mcp:mcp",+ "//third_party/devtools-frontend/mcp",]}--group("default") {- deps = [ ":devtools_deps" ]-}diff --git a/package.json b/package.jsonindex 45c9bb5e..b08c43e1 100644--- a/package.json+++ b/package.json@@ -12,8 +12,8 @@"cli:generate": "node scripts/generate-cli.ts","clean": "node scripts/clean.ts","clean:submodules": "node scripts/clean-submodules.ts",- "bundle": "npm run clean && npm run build && rollup -c rollup.config.js && node scripts/append-lighthouse-notices.ts",- "build": "node scripts/ninja.ts devtools_deps && tsc && node scripts/post-build.ts",+ "bundle": "npm run clean && npm run build && rollup -c rollup.config.js",+ "build": "node scripts/ninja.ts devtools_deps && tsc","typecheck": "node scripts/ninja.ts devtools_deps && tsc --noEmit","format": "eslint --cache --fix . && prettier --write --cache .","check-format": "eslint --cache . && prettier --check --cache .",diff --git a/rollup.config.js b/rollup.config.jsindex 0eda14e8..4cd4f510 100644--- a/rollup.config.js+++ b/rollup.config.js@@ -116,7 +116,6 @@ function getDevToolsThirdPartyDir(modulePath) {devtoolsThirdPartyBuildPath.length + absolutePathStart,);const pkg = relativePath.split(path.sep)[0];- // Ignore mocks generated by scripts/post-build.ts.if (!pkg || pkg === 'codemirror.next') {return null;}@@ -357,7 +356,19 @@ const bundleDependency = (const divider ='\n\n-------------------- DEPENDENCY DIVIDER --------------------\n\n';- return stringifiedDependencies.join(divider);+ const bundledNotices = stringifiedDependencies.join(divider).trim();+ const lighthouseNoticesPath = path.join(+ process.cwd(),+ 'src/third_party/LIGHTHOUSE_MCP_BUNDLE_THIRD_PARTY_NOTICES',+ );+ if (fs.existsSync(lighthouseNoticesPath)) {+ const lighthouseNotices = fs.readFileSync(+ lighthouseNoticesPath,+ 'utf-8',+ );+ return `${bundledNotices}${divider}${lighthouseNotices}`;+ }+ return bundledNotices;},},},diff --git a/scripts/append-lighthouse-notices.ts b/scripts/append-lighthouse-notices.tsdeleted file mode 100644index 1a3484bc..00000000--- a/scripts/append-lighthouse-notices.ts+++ /dev/null@@ -1,32 +0,0 @@-/**- * @license- * Copyright 2026 Google LLC- * SPDX-License-Identifier: Apache-2.0- */--import fs from 'node:fs';-import path from 'node:path';--const ROOT_DIR = process.cwd();-const TARGET_DIR = path.join(ROOT_DIR, 'out/Default/gen/src/third_party');-const SOURCE_DIR = path.join(ROOT_DIR, 'src/third_party');--function main() {- const lighthouseNotices = fs.readFileSync(- path.join(SOURCE_DIR, 'LIGHTHOUSE_MCP_BUNDLE_THIRD_PARTY_NOTICES'),- 'utf8',- );- const bundledNotices = fs.readFileSync(- path.join(TARGET_DIR, 'THIRD_PARTY_NOTICES'),- 'utf8',- );- fs.writeFileSync(- path.join(TARGET_DIR, 'THIRD_PARTY_NOTICES'),- bundledNotices +- '\n\n-------------------- DEPENDENCY DIVIDER --------------------\n\n' +- lighthouseNotices,- );- console.log('Done.');-}--main();diff --git a/scripts/copy-issue-descriptions.ts b/scripts/copy-issue-descriptions.tsnew file mode 100644index 00000000..f9c75e00--- /dev/null+++ b/scripts/copy-issue-descriptions.ts@@ -0,0 +1,17 @@+/**+ * @license+ * Copyright 2026 Google LLC+ * SPDX-License-Identifier: Apache-2.0+ */++import {cpSync, writeFileSync} from 'node:fs';++const [srcDir, destDir, stampFile] = process.argv.slice(2);+if (!srcDir || !destDir || !stampFile) {+ throw new Error(+ 'Usage: node copy-issue-descriptions.ts <srcDir> <destDir> <stampFile>',+ );+}++cpSync(srcDir, destDir, {recursive: true});+writeFileSync(stampFile, '');diff --git a/scripts/post-build.ts b/scripts/post-build.tsdeleted file mode 100644index 67aca10f..00000000--- a/scripts/post-build.ts+++ /dev/null@@ -1,41 +0,0 @@-/**- * @license- * Copyright 2025 Google LLC- * SPDX-License-Identifier: Apache-2.0- */--import * as fs from 'node:fs';-import * as path from 'node:path';--const GEN_DIR = path.join(process.cwd(), 'out', 'Default', 'gen');--async function main(): Promise<void> {- // Copy lighthouse bundle that tsc ignores due to lighthouse-devtools-mcp-bundle.d.ts- const lighthouseBundle = 'src/third_party/lighthouse-devtools-mcp-bundle.js';- const lighthouseBundleDest = path.join(GEN_DIR, lighthouseBundle);- fs.mkdirSync(path.dirname(lighthouseBundleDest), {recursive: true});- fs.copyFileSync(- path.join(process.cwd(), lighthouseBundle),- lighthouseBundleDest,- );-- // Copy issue descriptions generated by GN.- const descriptionsSrc = path.join(- GEN_DIR,- 'third_party',- 'devtools-frontend',- 'front_end',- 'models',- 'issues_manager',- 'descriptions',- );- const descriptionsDest = path.join(- GEN_DIR,- 'src',- 'third_party',- 'issue-descriptions',- );- fs.cpSync(descriptionsSrc, descriptionsDest, {recursive: true});-}--await main();diff --git a/src/BUILD.gn b/src/BUILD.gnnew file mode 100644index 00000000..029db963--- /dev/null+++ b/src/BUILD.gn@@ -0,0 +1,53 @@+# Copyright 2026 Google LLC+# SPDX-License-Identifier: Apache-2.0++import("//third_party/devtools-frontend/scripts/build/ninja/copy.gni")+import(+ "//third_party/devtools-frontend/scripts/build/typescript/typescript.gni")++copy_to_gen("lighthouse_bundle") {+ sources = [ "third_party/lighthouse-devtools-mcp-bundle.js" ]+}++action("issue_descriptions") {+ script = "//third_party/node/node.py"+ _script = "//scripts/copy-issue-descriptions.ts"+ _src_dir = "$root_gen_dir/third_party/devtools-frontend/front_end/models/issues_manager/descriptions"+ _dest_dir = "$target_gen_dir/third_party/issue-descriptions"+ _stamp = "$target_gen_dir/third_party/issue-descriptions.stamp"++ deps = [ "//third_party/devtools-frontend/front_end/models/issues_manager:descriptions" ]+ inputs = [ _script ]+ outputs = [ _stamp ]++ args = [+ rebase_path(_script, root_build_dir),+ rebase_path(_src_dir, root_build_dir),+ rebase_path(_dest_dir, root_build_dir),+ rebase_path(_stamp, root_build_dir),+ ]+}++ts_library("third_party") {+ runs_in = "node"++ sources = [+ "third_party/cli.ts",+ "third_party/devtools-formatter-worker.ts",+ "third_party/devtools-heap-snapshot-worker.ts",+ "third_party/index.ts",+ "third_party/lighthouse-devtools-mcp-bundle.d.ts",+ ]++ ts_deps = [+ "//third_party/devtools-frontend/front_end/core/root:bundle",+ "//third_party/devtools-frontend/front_end/entrypoints/formatter_worker:worker_entrypoint",+ "//third_party/devtools-frontend/front_end/entrypoints/heap_snapshot_worker:worker_entrypoint",+ "//third_party/devtools-frontend/mcp",+ ]++ deps = [+ ":issue_descriptions",+ ":lighthouse_bundle",+ ]+}