Monorepo Migration: Modular Architecture for Enhanced Development and Publishing
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 20/100
- issue の種類
- リファクタリング
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- rollup, typescript
調査の方向性
Start by reviewing the current package structure and build configuration, then compare them with the proposed six-package layout and TypeScript composite project setup. The issue is an architectural RFC with no files or tests identified; completion would require a migration plan and a proof of concept that supports the proposed package exports and backward compatibility.
索引モデルが issue の本文から書いたものです。
説明
Motivation
As @gravity-ui/graph continues to evolve, we need a more flexible architecture that enables:
- Independent Plugin Development: New layers and features can be developed and published without requiring a full library release
- Selective Consumption: Users can import only the parts they need, reducing bundle size
- Enhanced Tooling: Separate packages for development tools (devtools, minimap) that don't bloat the core library
- Better Maintenance: Clear separation of concerns makes the codebase easier to maintain and contribute to
- Ecosystem Growth: Third-party developers can more easily extend the library with custom layers and plugins
The current monolithic structure limits our ability to iterate quickly on supplementary features while maintaining stability in the core library.
Proposed Solution
Transform @gravity-ui/graph into a monorepo with 6 focused packages:
Package Architecture
graph LR
subgraph "Main Package with Routing"
MAIN["@gravity-ui/graph<br/>package.json with exports routing"]
end
subgraph "Internal Packages"
PRIM["@gravity-ui/graph-primitives<br/>• shapes: curvePolyline, triangle, polyline<br/>• renderers: text, svg, render<br/>• basic types: TPoint, TRect, IPoint, IRect<br/>• simple utils: clamp"]
CORE["@gravity-ui/graph-core<br/>• lib/: CoreComponent, Component, Scheduler<br/>• store/: RootStore, blocks, connections<br/>• services/: Layer, Camera, HitTest<br/>• components/canvas/<br/>• api/: PublicGraphApi<br/>• graph.ts: main class<br/>• utils/functions, utils/types"]
REACT["@gravity-ui/graph-react<br/>• GraphCanvas<br/>• hooks: useGraph, useLayer<br/>• React components"]
DEVTOOLS["@gravity-ui/graph-devtools<br/>• DevToolsLayer<br/>• ruler and crosshairs"]
MINIMAP["@gravity-ui/graph-minimap<br/>• MiniMapLayer<br/>• navigation minimap"]
end
PRIM --> CORE
PRIM --> REACT
CORE --> REACT
CORE --> DEVTOOLS
CORE --> MINIMAP
CORE --> MAIN
REACT --> MAIN
DEVTOOLS --> MAIN
MINIMAP --> MAIN
Package Details
1. @gravity-ui/graph-primitives
Foundation package with basic building blocks
- Geometric shapes (
curvePolyline,triangle,polyline) - Rendering utilities (
text,svg,render) - Core types (
TPoint,TRect,IPoint,IRect) - Simple utilities (
clamp, basic math functions)
2. @gravity-ui/graph-core
Consolidated core functionality
- Component system (
lib/) - State management (
store/) - Core services (
services/) - Canvas components (
components/canvas/) - Public API (
api/,graph.ts) - Remaining utilities
Rationale: These modules are tightly coupled and only valuable together
3. @gravity-ui/graph-react
React integration layer
GraphCanvascomponent- React hooks (
useGraph,useLayer, etc.) - React-specific components and utilities
4. @gravity-ui/graph-devtools
Development tools plugin
- DevTools layer with rulers and crosshairs
- Independent package for development-time features
- Peer dependency on
@gravity-ui/graph-core
5. @gravity-ui/graph-minimap
Navigation minimap plugin
- Minimap layer for graph navigation
- Independent package for optional UI enhancement
- Peer dependency on
@gravity-ui/graph-core
6. @gravity-ui/graph
Main package with routing
- Consolidates all packages with proper exports
- Maintains backward compatibility
- Provides clean API surface
Implementation Plan
Phase 1: Monorepo Setup
packages/
├── primitives/ # @gravity-ui/graph-primitives
├── core/ # @gravity-ui/graph-core
├── react/ # @gravity-ui/graph-react
├── devtools/ # @gravity-ui/graph-devtools
├── minimap/ # @gravity-ui/graph-minimap
└── graph/ # @gravity-ui/graph (main with routing)
Phase 2: Package Configuration
Main package package.json with exports routing:
{
"name": "@gravity-ui/graph",
"exports": {
".": {
"types": "./dist/core/index.d.ts",
"default": "./dist/core/index.js"
},
"./react": {
"types": "./dist/react/index.d.ts",
"default": "./dist/react/index.js"
},
"./primitives": {
"types": "./dist/primitives/index.d.ts",
"default": "./dist/primitives/index.js"
},
"./devtools": {
"types": "./dist/devtools/index.d.ts",
"default": "./dist/devtools/index.js"
},
"./minimap": {
"types": "./dist/minimap/index.d.ts",
"default": "./dist/minimap/index.js"
}
}
}
Phase 3: Migration Strategy
- Create packages structure while maintaining single build output
- Update internal dependencies and imports
- Configure build system and publishing workflow
- Update documentation and examples
Tools and Technologies
Build System
- TypeScript Composite Projects: Use TypeScript's composite option for incremental builds and project references
- Rollup: For optimized bundling and tree-shaking support
- Shared build configuration: Consistent build setup across all packages
Publishing and Versioning
- Changesets: Industry-standard tool for managing versions and changelogs in monorepos
- Independent versioning: Each package can evolve at its own pace
- Coordinated releases: Core updates can trigger dependent package updates
Development Workflow
- Workspaces: npm/yarn workspaces for dependency management
- Shared tooling: ESLint, Prettier, TypeScript configs
- Cross-package development: Easy local development with package linking
Benefits
For Users
- Smaller bundles: Import only needed functionality
- Faster adoption: Try specific features without full library commitment
- Clear upgrade paths: Update individual packages as needed
For Maintainers
- Independent releases: Ship devtools improvements without core library changes
- Clear boundaries: Easier to reason about code organization
- Better testing: Isolated testing per package
- Community contributions: Easier for contributors to focus on specific areas
For Ecosystem
- Plugin development: Clear pattern for extending with custom layers
- Third-party tools: Better foundation for community-built extensions
- Framework integration: Other frameworks can consume core without React dependencies
Backward Compatibility
The main @gravity-ui/graph package will maintain 100% backward compatibility through proper exports routing. Existing users won't need to change any import statements.
Next Steps
- Community feedback on this RFC
- Proof of concept with TypeScript composite setup
- Migration timeline planning
- Documentation updates for new architecture
This migration represents a significant step toward a more modular, maintainable, and extensible @gravity-ui/graph ecosystem while preserving the seamless developer experience users expect.
- 主要言語
- TypeScript
- スター
- 145
- フォーク
- 12
- 平均マージ
- 1日 14時間
- マージ済み PR(30日)
- 43
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
gravity-ui/graph のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
gravity-ui/graph#457 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
gravity-ui/graph#455 ·
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 55/100
gravity-ui/graph#456 ·
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
gravity-ui/graph#431 ·
メンテナーはふだん 1 日以内に返信
-
proposal
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
gravity-ui/graph#416 ·
メンテナーはふだん 1 日以内に返信
gravity-ui/graph の issue をすべて見る
似ている issue
-
area:cli area:security bug priority:medium
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
"code source" and "numerique.gouv" links: "new window" mention duplicated in the accessible nameオープンaccessibility
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
numerique-gouv/lasuite-landingpage#315 ·
メンテナーはふだん 1 日以内に返信
-
needs:triage
難易度 1/5 1時間未満 初心者へのやさしさ 92/100
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 72/100
HyeokjaeChoi/vaultme#585 ·
メンテナーはふだん 1 日以内に返信
-
enhancement priority/P2
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
beettlle/pi-smart-router#200 ·