antd v3 Support Design#
Overview#
Add support for antd 3.x to enable migration assistance and legacy project queries.
Goals#
- Migration assistance — Help users migrate from v3 to v4/v5/v6 with
antd migrate 3 4 - Legacy project support — Full query feature support for projects still on v3 (info, demo, doc, props query)
Non-Goals#
- Token system support for v3 (v3 uses Less variables, not Design Tokens)
- Semantic structure support for v3 (v3 doesn't have classNames/styles)
- Per-minor version snapshots (only final version 3.26.20)
Design Details#
1. Data Layer#
File structure:
data/
├── v3.json # v3 entry point (identical to v3.26.20)
├── v3.26.20.json # v3 final version snapshot
└── versions.json # add v3 entry
versions.json addition:
{
"v3": {
"3.26": "3.26.20"
}
}
Extraction script modifications (scripts/extract.ts):
- v3 frontmatter uses
typefield for sub-category (v4+ usesgroup), already handled byresolveCategory() - v3 has no
_semantic.tsxfiles, semantic data will be empty (already handled) - v3 has no
token-meta.json, token data will be empty (already handled) - Add branch detection for
3.x-stable
Data compatibility:
- v3 documentation structure is similar to v4+ (frontmatter + markdown)
- API tables follow the same format
- No changes needed to
loadMetadata()orloadMetadataForVersion()
2. Command Support Matrix#
| Command | v3 Support | Notes |
|---|---|---|
list | ✅ Full | Component listing |
info | ✅ Full | Props API query |
doc | ✅ Full | Documentation output |
demo | ✅ Full | Demo code |
token | ❌ Error | UNSUPPORTED_VERSION_FEATURE |
semantic | ❌ Error | UNSUPPORTED_VERSION_FEATURE |
changelog | ✅ Full | Changelog entries |
doctor | ✅ Full | Project diagnostics |
usage | ✅ Full | Usage analysis |
lint | ✅ Full | Code linting |
migrate | ✅ Enhanced | v3→v4 migration knowledge |
3. Error Handling for Unsupported Features#
Return friendly error messages for v3-incompatible commands:
{
"error": true,
"code": "UNSUPPORTED_VERSION_FEATURE",
"message": "Design Tokens are only available in antd v5+",
"suggestion": "v3 uses Less variables for theming. See: https://3x.ant.design/docs/react/customize-theme"
}
4. Enhanced Migration Support (v3→v4)#
New migration knowledge module (src/commands/migrate-v3-to-v4.ts):
Key migration items:
- Icon: String
typeprop removed → Use@ant-design/iconscomponents - Mention: Removed → Use
Mentions - Form.create(): Removed → Use
Form.useForm()hook - Form.getFieldDecorator: Removed → Use
Form.Item nameprop - BackTop: Works in v4, deprecated in v5 → Use
FloatButton.BackTopin v5+ - Less variables: Supported in v4, replaced by CSS-in-JS in v5
Migration output example (antd migrate 3 4):
{
"from": "3",
"to": "4",
"steps": [
{
"component": "Icon",
"breaking": true,
"description": "Icon with string `type` prop removed. Use @ant-design/icons components instead",
"autoFixable": false,
"guide": "https://ant.design/docs/react/migrate-v4#icon"
},
{
"component": "BackTop",
"breaking": true,
"description": "BackTop is removed, use FloatButton.BackTop instead",
"autoFixable": true,
"codemod": "v4-import-rename"
}
],
"summary": {"total": 15, "autoFixable": 5, "manual": 10}
}
Implementation Plan#
Phase 1: Data Extraction#
- Modify
scripts/extract.tsto handle v3-specific differences - Create
scripts/extract-v3.tsor add branch detection in extract.ts - Generate
data/v3.jsonanddata/v3.26.20.jsonfrom3.x-stablebranch - Update
data/versions.json
Phase 2: Command Updates#
- Add version check in
tokencommand for v3 error message - Add version check in
semanticcommand for v3 error message - Test all other commands work with v3 data
Phase 3: Migration Enhancement#
- Create
src/commands/migrate/v3-to-v4.tswith migration knowledge - Update
migratecommand to recognize v3→v4 path - Add v3-specific migration items
Phase 4: Testing#
- Add unit tests for v3 data loading
- Add e2e tests for v3 commands
- Test migration command with v3 projects
Risks#
- v3 documentation differences — May need additional handling for edge cases
- Package size — Adding v3 data increases bundle size (~1-2MB compressed)
- Maintenance burden — v3 is EOL, unlikely to need updates after initial implementation
Alternatives Considered#
- Separate package — Rejected: Adds user friction for a small feature
- Full minor snapshots — Rejected: Overkill for EOL version, only one version needed
- Less variables for token command — Rejected: Too much effort for low usage