Agent Skills › ag-grid/ag-charts › module-definitions

module-definitions

GitHub

定义图表模块声明规范,明确选项贡献路径、验证及主题默认值合并逻辑。指导如何正确注册模块以避免未注册错误或类型不支持报错,确保生成表格与 ESLint 校验一致。

.rulesync/skills/module-definitions/SKILL.md ag-grid/ag-charts

Trigger Scenarios

创建新模块或迁移功能到模块 添加模块拥有的选项路径 修复'required modules are not registered'报告错误 修正 module-registration lint 错误

Install

npx skills add ag-grid/ag-charts --skill module-definitions -g -y
More Options

Non-standard path

npx skills add https://github.com/ag-grid/ag-charts/tree/latest/.rulesync/skills/module-definitions -g -y

Use without installing

npx skills use ag-grid/ag-charts@module-definitions

指定 Agent (Claude Code)

npx skills add ag-grid/ag-charts --skill module-definitions -a claude-code -g -y

安装 repo 全部 skill

npx skills add ag-grid/ag-charts --all -g -y

预览 repo 内 skill

npx skills add ag-grid/ag-charts --list

SKILL.md

Frontmatter
{
    "name": "module-definitions",
    "targets": [
        "*"
    ],
    "description": "Add or change an AG Charts module definition: which options it owns, how community reports it when missing, how its theme defaults and validation reach the chart, and how the generated module tables stay in step. Use when creating a module, moving a feature into one, adding an option path a module owns, or when a \"required modules are not registered\" report or the module-registration lint is wrong."
}

Module Definitions and Option Contributions

A ModuleDefinition is the single place a feature declares itself. Its type decides the lifecycle (chart, axis, series, plugin, axis:plugin, series:plugin, preset). Its option contributions decide which locations in the options tree it owns. Everything downstream derives from these two facts:

  • first-pass validation defs for module-owned locations (composeChartOptionsDefs),
  • the "required modules are not registered" report and the stripping of unowned options,
  • stripping options a chart type does not support (Option \x` is not supported by `pie` series`),
  • theme defaults merged from themeTemplate at the contributed path,
  • the runtime decision to instantiate an axis or series plugin,
  • the generated placeholder table in community and the ESLint example-validation mappings.

Never add a consumer that special-cases a module by name or option key. If a consumer needs to know about a location, the owning module must declare it.

When contributes is implied

Most modules own exactly the location their type implies, and declare nothing:

Type Implied location Requested when
plugin <name> at the chart root non-null and not { enabled: false }
axis:plugin axes[].<optionsKey ?? name> as above
series:plugin series[].<name> any non-null value ('present')

Chart, axis, series and preset modules own whole subtrees by identity and contribute nothing.

When to declare contributes

Declare it when the module owns options anywhere else, or owns several locations:

export const AxisInteractionModule: PluginModuleDefinition<never> = {
    type: 'plugin',
    name: 'axis-interaction',
    chartTypes: ['cartesian'],
    enterprise: true,
    version: VERSION,
    contributes: [
        { path: 'axes[].listeners.click', options: callback },
        { path: 'listeners.axisClick', options: callback },
    ],
    create: (ctx) => new AxisInteraction(ctx),
};

Each contribution:

  • path: dotted, with [] marking a segment whose every child is a host (axes[], series[]). The first segment decides the host: axes[] is the axis host, series[] the series host, anything else the chart host.
  • options: validation for the subtree, or one validator for a leaf such as a callback. Omit it to keep whatever the chart defs already declare there.
  • themeTemplate: defaults merged at the path.
  • chartTypes / axisTypes / seriesTypes: where the location applies. A contribution without chartTypes inherits the definition's; omitting the list applies everywhere, while an empty list applies nowhere.
  • requested: 'enabled' (default) or 'present', deciding whether a supplied value counts as a request for the missing module.
  • apiName: a public name for the report when the path alone reads badly.

A module with neither options nor a themeTemplate owns no option location at all (internal dependencies, the community series area), so it declares nothing.

Community and enterprise pairs

An enterprise module with the same name and version as a community one replaces it on registration (enterprise: true). Reserve this for a module whose behaviour the enterprise build changes wholesale; the generated placeholder then names the enterprise variant.

Contributing into another module's options

A feature that lives under another module's option key is its own module, not an override of the host. BackgroundRegionsModule declares contributes: [{ path: 'seriesArea.backgroundRegions', ... }] and depends on the community SeriesAreaModule, which exposes itself as the seriesArea service. Every chart module depends on that service, so ctx.seriesArea is never optional. The feature implements SeriesAreaContent and calls ctx.seriesArea.attach(this) to render inside the series area. The host reads the keys other modules contribute below its path through contributedKeysUnder and leaves them alone, so it validates only its own options.

Presets that users reach through an API entry point declare apiName: 'AgCharts.createGauge' so the report names the entry point rather than the registry name.

Generated tables

packages/ag-charts-enterprise/src/moduleTables.test.ts derives from the exported definitions:

  • packages/ag-charts-community/src/chart/factory/expectedModules.generated.ts
  • libraries/ag-charts-eslint-rules/rules/module-mappings.generated.mjs

and asserts that the documentation module list names only exported module ids. After changing a definition, a bundle, or a main.ts export, regenerate:

UPDATE_MODULE_TABLES=1 yarn nx test ag-charts-enterprise -- moduleTables
yarn nx format

The test fails until the files are regenerated. Do not edit the generated files. A module reachable only through a bundle is named after the smallest exported bundle that carries it.

libraries/ag-charts-eslint-rules/rules/module-mappings.mjs keeps only what definitions do not carry (default axes per series, intrinsic defaults, the cross-line listener owners) and merges it with the generated tables.

Checklist for a new module

  1. Write the definition with type, name, version, create, and options/themeTemplate. Put undocumented keys inside the options literal with ...undocumentedDefs({...}), never by assigning onto it afterwards, which keeps it out of tree-shaking (see the api-contracts rule).
  2. Declare contributes only if the implied location is wrong or incomplete. It replaces the implied location, so when adding locations, list the implied one alongside them.
  3. Export it from the package main.ts and add it to the relevant module-bundles/*.ts.
  4. Regenerate the tables and run yarn nx test ag-charts-community -- optionsModule so the parametrised contract test covers the new contribution.
  5. Add the module to packages/ag-charts-website/src/content/module-mappings/modules.json if it is user-facing.

Version History

  • 39cb99b Current 2026-10-19 05:36

    核心代码改为树可摇以支持集成导出;显式 contributes 替代隐含所有权规则;新增 undocumentedDefs 模式文档及 bundle 对比工具。

  • 4f5d825 2026-09-27 22:39

    插件定义现支持以列表形式声明 chartTypes,允许单一定义覆盖多种图表类型,优化了运行时匹配逻辑。

  • fd55d17 2026-09-22 10:50

Same Skill Collection

.rulesync/skills/animation-test-migration/SKILL.md
.rulesync/skills/chart-defaults/SKILL.md
.rulesync/skills/hot-paths/SKILL.md
.rulesync/skills/port-showcases/SKILL.md
.rulesync/skills/technology-stack/SKILL.md
tools/prompts/skills/estimate-jira/SKILL.md

Metadata

Files
0
Version
39cb99b
Hash
294297ef
Indexed
2026-09-22 10:50

홈 - 위키
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-10-28 15:11
浙ICP备14020137号-1