一键导入
devtools-module-merging
Workflow for merging a DevTools submodule into its parent module. Covers BUILD.gn consolidation and updating devtools_grd_files.gni.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Workflow for merging a DevTools submodule into its parent module. Covers BUILD.gn consolidation and updating devtools_grd_files.gni.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Use when migrating Chromium layout tests to DevTools unit tests
Use when starting a new task, creating a branch, switching branches, managing branches, creating and uploading CLs, handling stacked changes, or checking release and roll status in the DevTools Gerrit-based workflow. ALWAYS use this instead of running standard git checkout/switch commands for branch creation.
Reproduce and investigate flakiness in a test.
Refactor user-facing UIStrings and localization comments in a DevTools module folder according to UX writing guidelines (child task of b/40799900). Use when simplifying wording, checking sentence case, or improving L10n comments in UIStrings for a specific folder or issue. Don’t use for general code changes or non-UIStrings files.
Migrates legacy imperative DOM construction to local declarative Lit-html templates rendered inside existing containers.
Consolidates manual DOM creation, updates, and constructors into private helper methods and structured state interfaces.
| name | devtools-module-merging |
| description | Workflow for merging a DevTools submodule into its parent module. Covers BUILD.gn consolidation and updating devtools_grd_files.gni. |
This document outlines the process for merging a submodule (e.g., panels/timeline/extensions) into its parent module (e.g., panels/timeline) within the DevTools build system. The goal is to simplify the build configuration by consolidating BUILD.gn files while keeping the original source file directory structure.
You will need the following information:
Read the contents of the BUILD.gn file from both the child module and the parent module. Identify the following from the child's BUILD.gn:
sources in the devtools_module.deps (dependencies) in the devtools_module.entrypoint for the devtools_entrypoint("bundle").BUILD.gnEdit the BUILD.gn file in the parent module's directory to incorporate the child module's configuration.
sources from the child's devtools_module to the parent's sources list. Remember to maintain the relative path from the parent's directory (e.g., extensions/ExtensionUI.ts).deps from the child's devtools_module to the parent's deps list. Remove any duplicate entries.deps list (e.g., remove ./extensions:bundle).BUILD.gnOnce the parent BUILD.gn is updated and contains all the necessary information, the child's BUILD.gn is no longer needed. Delete it.
rm <child_module_path>/BUILD.gn
devtools_grd_files.gniThe global .gni file that lists all resources needs to be updated to reflect that the child module is no longer a separate, bundled entrypoint.
config/gni/devtools_grd_files.gni.grd_files_bundled_sources list. This path usually corresponds to the child's entrypoint..ts) to the grd_files_unbundled_sources list.panels/timeline/extensions into panels/timelinepanels/timelinepanels/timeline/extensionspanels/timeline/BUILD.gn ModificationBefore:
devtools_module("timeline") {
sources = [
...
"UIDevtoolsUtils.ts",
]
deps = [
...
"./components:bundle",
"./extensions:bundle",
"./overlays:bundle",
...
]
}
After:
devtools_module("timeline") {
sources = [
...
"UIDevtoolsUtils.ts",
"extensions/ExtensionUI.ts", # Added from child
]
deps = [
...
"./components:bundle",
# "./extensions:bundle", # Removed
"./overlays:bundle",
...
# Dependencies from extensions/BUILD.gn are merged here
"../../../ui/components/helpers:bundle",
"../../../ui/components/render_coordinator:bundle",
"../../../ui/legacy:bundle",
]
}
panels/timeline/extensions/BUILD.gn Deletionrm front_end/panels/timeline/extensions/BUILD.gn
config/gni/devtools_grd_files.gni ModificationBefore:
grd_files_bundled_sources = [
...
"front_end/panels/timeline/components/components.js",
"front_end/panels/timeline/extensions/extensions.js",
"front_end/panels/timeline/overlays/overlays.js",
...
]
grd_files_unbundled_sources = [
...
"front_end/panels/timeline/extensions/ExtensionUI.ts", # This might not have been present before
...
]
After:
grd_files_bundled_sources = [
...
"front_end/panels/timeline/components/components.js",
# "front_end/panels/timeline/extensions/extensions.js", # Removed
"front_end/panels/timeline/overlays/overlays.js",
...
]
grd_files_unbundled_sources = [
...
"front_end/panels/timeline/extensions/extensions.ts", # Added
"front_end/panels/timeline/extensions/ExtensionUI.ts", # Added
...
]
After merging modules, you may still have remaining barrel files (e.g. index.ts or extensions.ts that just re-export other files). These should be removed to simplify the module structure.
Manually updating all imports that rely on these barrels can be tedious and error-prone. The tool unbarrelify can automate this process. It analyzes your codebase and replaces imports from barrel files with direct imports from the source files.
Usage: Follow the instructions in the unbarrelify repository to install and run the tool on your project. This is highly recommended to complete the refactoring process efficiently.