Skip to content

Commit fcd6008

Browse files
committed
doc: Improve package architecture documentation and add options for managing dependencies
1 parent 01db8d5 commit fcd6008

File tree

2 files changed

+60
-1
lines changed

2 files changed

+60
-1
lines changed

docs/ts-graphviz/11-advanced-topics/02-package-architecture.md

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,35 @@ description: Package architecture of ts-graphviz.
1717

1818
- **`@ts-graphviz/react`**: Allows defining graphs using React's declarative UI paradigm, expressing DOT language models with JSX.
1919

20-
## Dependency Graph
20+
## Exposing Internal Modules as Submodules
21+
22+
**ts-graphviz** publishes some of its internal modules as submodules within the main package. Specifically, the following import paths are available to access these internal modules:
23+
24+
- **`ts-graphviz/ast`** or **`@ts-graphviz/ast`**
25+
- **`ts-graphviz/adapter`** or **`@ts-graphviz/adapter`**
26+
27+
This allows users to choose the module import style that best fits their project's needs. By using the `ts-graphviz/<module-name>` style, you can limit your dependencies to the `ts-graphviz` library itself, with internal packages (e.g., `@ts-graphviz/adapter`, `@ts-graphviz/ast`) being managed centrally by the `ts-graphviz` package. On the other hand, using the `@ts-graphviz/<module-name>` style enables you to manage dependencies on a per-module basis, allowing you to selectively install specific modules as needed.
28+
29+
:::tip Managing Dependencies When Choosing Import Paths
30+
31+
When using package managers that enforce strict dependency management (e.g., pnpm), the choice of import path can significantly impact how dependencies are handled. Consider the following points:
32+
33+
- **Using `ts-graphviz/<module-name>` Style**:
34+
- **Advantages**: Limits dependencies to the `ts-graphviz` library itself, with internal packages (e.g., `@ts-graphviz/adapter`, `@ts-graphviz/ast`) being managed centrally by the `ts-graphviz` package. This prevents dependency conflicts and ensures that stable versions recommended by the library are used.
35+
- **Recommended Scenarios**: When you want to minimize dependencies or when the internal packages managed by `ts-graphviz` do not have specific version requirements.
36+
37+
- **Using `@ts-graphviz/<module-name>` Style**:
38+
- **Advantages**: Allows you to manage dependencies on a per-module basis, installing only the specific modules you need, which can help keep your application lightweight.
39+
- **Caveats**: Requires you to manage internal dependencies (e.g., `@ts-graphviz/adapter`, `@ts-graphviz/ast`) separately within your package manager. This can complicate version management.
40+
- **Recommended Scenarios**: When you need to use specific modules only or require detailed control over your dependencies.
41+
42+
**Summary**:
43+
- If you prefer **simple dependency management**, use the `ts-graphviz/<module-name>` style.
44+
- If you require **fine-grained control over dependencies** or only need specific modules, opt for the `@ts-graphviz/<module-name>` style.
45+
46+
This approach allows you to manage dependencies in a way that best suits your project's requirements.
47+
:::
48+
2149

2250
The relationships between packages can be visualized as follows:
2351

i18n/ja/docusaurus-plugin-content-docs/current/ts-graphviz/11-advanced-topics/02-package-architecture.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,37 @@ description: ts-graphvizのパッケージアーキテクチャ
1717

1818
- **`@ts-graphviz/react`**: Reactの宣言的UIパラダイムを使用してグラフを定義することを可能にし、JSXでDOT言語モデルを表現します。
1919

20+
## サブモジュールとしての内部モジュールの公開
21+
22+
**ts-graphviz** パッケージは、内部モジュールの一部をサブモジュールとして公開しています。具体的には、以下のインポートパスを利用して内部モジュールにアクセスできます:
23+
24+
- **`ts-graphviz/ast`** または **`@ts-graphviz/ast`**
25+
- **`ts-graphviz/adapter`** または **`@ts-graphviz/adapter`**
26+
27+
これにより、ユーザーはプロジェクトのニーズに応じて柔軟にモジュールを選択できます。
28+
`ts-graphviz/<モジュール名>` スタイルを使用することで、`ts-graphviz` ライブラリ自体のみに依存関係を絞り、内部パッケージ(例: `@ts-graphviz/adapter``@ts-graphviz/ast`)のバージョンは `ts-graphviz` パッケージによって一元管理されます。
29+
一方、`@ts-graphviz/<モジュール名>` スタイルを使用すると、必要な機能ごとに個別に依存関係を管理でき、特定のモジュールのみを選択的にインストールすることが可能です。
30+
31+
:::tip インポートパス選択時の依存関係管理
32+
33+
依存関係を厳密に管理するパッケージマネージャー(例: pnpm)を使用する場合、インポートパスの選択が依存関係の管理に大きな影響を与えることがあります。以下のポイントを参考にしてください:
34+
35+
- **`ts-graphviz/<モジュール名>` スタイルの利用**:
36+
- **利点**: `ts-graphviz` ライブラリ自体のみに依存関係を絞ることができ、内部パッケージ(例: `@ts-graphviz/adapter``@ts-graphviz/ast`)のバージョンは `ts-graphviz` パッケージによって一元管理されます。これにより、依存関係の衝突を防ぎ、ライブラリの推奨に基づいた安定したバージョンが使用されます。
37+
- **推奨シナリオ**: 依存関係を最小限に抑えたい場合や、`ts-graphviz` が内部で管理する依存パッケージに特別なバージョン要件がない場合。
38+
39+
- **`@ts-graphviz/<モジュール名>` スタイルの利用**:
40+
- **利点**: 必要な機能ごとに個別に依存関係を管理できるため、特定のモジュールのみを選択的にインストールし、アプリケーションの軽量化が図れます。
41+
- **注意点**: パッケージマネージャーで内部依存パッケージ(例: `@ts-graphviz/adapter``@ts-graphviz/ast`)も個別に管理する必要があります。これにより、依存関係のバージョン管理が複雑になる可能性があります。
42+
- **推奨シナリオ**: 特定のモジュールのみを使用したい場合や、依存関係の詳細な管理が必要な場合。
43+
44+
**まとめ**:
45+
- **シンプルな依存関係管理**を希望する場合は、`ts-graphviz/<モジュール名>` スタイルを使用してください。
46+
- **細かな依存関係の管理**や、特定のモジュールのみを利用したい場合は、`@ts-graphviz/<モジュール名>` スタイルを選択してください。
47+
48+
これにより、プロジェクトのニーズに最適な依存関係管理が可能となります。
49+
:::
50+
2051
## 依存関係グラフ
2152

2253
パッケージ間の関係は以下のように視覚化できます:

0 commit comments

Comments
 (0)