Agent SkillsChromeDevTools/devtools-frontend › merging-devtools-module

merging-devtools-module

GitHub

规范 DevTools 子模块合并至父模块的构建流程,包括整合 BUILD.gn、移除冗余依赖及更新资源列表 gni 文件,旨在简化构建配置。

.agents/skills/merging-devtools-module/SKILL.md ChromeDevTools/devtools-frontend

Trigger Scenarios

需要合并 DevTools 子模块到父模块 整理和优化 DevTools 构建配置文件

Install

npx skills add ChromeDevTools/devtools-frontend --skill merging-devtools-module -g -y
More Options

Non-standard path

npx skills add https://github.com/ChromeDevTools/devtools-frontend/tree/main/.agents/skills/merging-devtools-module -g -y

Use without installing

npx skills use ChromeDevTools/devtools-frontend@merging-devtools-module

指定 Agent (Claude Code)

npx skills add ChromeDevTools/devtools-frontend --skill merging-devtools-module -a claude-code -g -y

安装 repo 全部 skill

npx skills add ChromeDevTools/devtools-frontend --all -g -y

预览 repo 内 skill

npx skills add ChromeDevTools/devtools-frontend --list

SKILL.md

Frontmatter
{
    "name": "merging-devtools-module",
    "description": "Workflow for merging a DevTools submodule into its parent module. Covers BUILD.gn consolidation and updating devtools_grd_files.gni."
}

Workflow: Merging a DevTools Submodule into its Parent

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.

Prerequisites

You will need the following information:

  • Parent Module Path: The path to the directory containing the primary module.
  • Child Module Path: The path to the directory of the submodule to be merged.

Workflow Steps

1. Analyze Build Configurations

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:

  • The list of sources in the devtools_module.
  • The list of deps (dependencies) in the devtools_module.
  • The entrypoint for the devtools_entrypoint("bundle").

2. Modify the Parent BUILD.gn

Edit the BUILD.gn file in the parent module's directory to incorporate the child module's configuration.

  1. Add Child's Sources: Append the list of 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).
  2. Merge Dependencies: Add the deps from the child's devtools_module to the parent's deps list. Remove any duplicate entries.
  3. Remove Child Bundle Dependency: Delete the dependency on the child's bundle from the parent's deps list (e.g., remove ./extensions:bundle).

3. Delete the Child BUILD.gn

Once 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

4. Update devtools_grd_files.gni

The global .gni file that lists all resources needs to be updated to reflect that the child module is no longer a separate, bundled entrypoint.

  1. Locate and Read the File: Open config/gni/devtools_grd_files.gni.
  2. Remove Bundled Source: Find and remove the line for the child's bundled JavaScript file from the grd_files_bundled_sources list. This path usually corresponds to the child's entrypoint.
  3. Add Unbundled Sources: Add the paths to all of the child's original TypeScript source files (.ts) to the grd_files_unbundled_sources list.

Example: Merging panels/timeline/extensions into panels/timeline

  • Parent Module: panels/timeline
  • Child Module: panels/timeline/extensions

1. panels/timeline/BUILD.gn Modification

Before:

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",
  ]
}

2. panels/timeline/extensions/BUILD.gn Deletion

rm front_end/panels/timeline/extensions/BUILD.gn

3. config/gni/devtools_grd_files.gni Modification

Before:

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
  ...
]

Removing Barrel Files

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.

Version History

  • 678d19c Current 2026-08-20 15:20

Same Skill Collection

.agents/skills/devtools-ci/SKILL.md
.agents/skills/devtools-imports/SKILL.md
.agents/skills/devtools-model-management/SKILL.md
.agents/skills/devtools-setting-migration/SKILL.md
.agents/skills/devtools-source-maps/SKILL.md
.agents/skills/devtools-testing-guidance/SKILL.md
.agents/skills/devtools-unicode-escaping/SKILL.md
.agents/skills/devtools-ux-writing-refactor/SKILL.md
.agents/skills/devtools-verification/SKILL.md
.agents/skills/evaluate-ai-css-completion/SKILL.md
.agents/skills/fixing-skipped-tests/SKILL.md
.agents/skills/foundation-test-migration/SKILL.md
.agents/skills/gerrit-cli/SKILL.md
.agents/skills/migrate-chromium-test/SKILL.md
.agents/skills/ui-eng-vision-local-lit-renderer/SKILL.md
.agents/skills/ui-eng-vision-logic-consolidator/SKILL.md
.agents/skills/ui-eng-vision-orchestrator/SKILL.md
.agents/skills/ui-eng-vision-test-scaffolder/SKILL.md
.agents/skills/ui-eng-vision-widget-promoter/SKILL.md
.agents/skills/ui-widgets/SKILL.md
.agents/skills/version-control/SKILL.md
.agents/skills/repro-flaky-tests/SKILL.md

Metadata

Files
0
Version
678d19c
Hash
e30aa6db
Indexed
2026-08-20 15:20

- 위키
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-08-24 20:44
浙ICP备14020137号-1 $방문자$