From e683c26427defced6e9851eff1c20ae64822c108 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 4 Feb 2026 01:17:26 +0000 Subject: [PATCH 1/3] Add proposal for separating CompiledInjector from Compiler This proposal outlines the plan to split Ray.Compiler into two packages: - ray/compiled-injector: Runtime execution (11KB, production dependency) - ray/compiler: Build tool (35KB, dev dependency) Benefits: - Security: Remove compilation code from production - Size: 75% reduction in production deployment - Clarity: Clear separation of runtime vs build-time concerns - Simple migration: Only composer.json changes needed The proposal includes: - Detailed implementation plan (Phase 1-3) - File classification and migration checklist - Package structure and composer.json specifications - Migration guide for existing users --- SEPARATION_PROPOSAL.md | 328 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 328 insertions(+) create mode 100644 SEPARATION_PROPOSAL.md diff --git a/SEPARATION_PROPOSAL.md b/SEPARATION_PROPOSAL.md new file mode 100644 index 00000000..913135c0 --- /dev/null +++ b/SEPARATION_PROPOSAL.md @@ -0,0 +1,328 @@ +# CompiledInjector分離提案 + +## 目的 + +Ray.Compilerから**ランタイム実行部分**(CompiledInjector)を分離し、**ビルドツール部分**(Compiler)と明確に分ける。 + +- ランタイム → `ray/compiled-injector` (本番依存) +- ビルドツール → `ray/compiler` (開発依存) + +## メリット + +1. **セキュリティ向上**: コンパイル処理(リフレクション、ファイル書き込み、コード生成)を本番から除外 +2. **デプロイサイズ削減**: 約35KBのビルドツールを本番から除外 +3. **責務の明確化**: TypeScript/tscと同様の関係性 +4. **依存関係の単純化**: Ray.Di/Aopはそのまま(変更なし) + +## パッケージ構成 + +### ray/compiled-injector (新規) + +**目的**: コンパイル済みスクリプトの実行 + +``` +ray/compiled-injector/ +├── composer.json +├── src/ +│ ├── CompiledInjector.php +│ ├── ScriptInjectorInterface.php +│ ├── InjectionPoint.php +│ ├── Types.php +│ └── Exception/ +│ ├── ExceptionInterface.php +│ ├── ClassNotFound.php +│ ├── Unbound.php +│ ├── ScriptFileNotFound.php +│ └── ScriptDirNotReadable.php +└── src-function/ + ├── singleton.php + └── prototype.php +``` + +**composer.json**: +```json +{ + "name": "ray/compiled-injector", + "description": "Runtime for Ray.Compiler pre-compiled dependency injection scripts", + "keywords": ["di", "runtime"], + "license": "MIT", + "require": { + "php": "^8.2", + "ray/di": "^2.19", + "ray/aop": "^2.18" + }, + "autoload": { + "psr-4": { + "Ray\\Compiler\\": "src" + }, + "files": [ + "src-function/singleton.php", + "src-function/prototype.php" + ] + }, + "suggest": { + "ray/compiler": "Required for compiling DI containers at build time" + } +} +``` + +サイズ: **約11KB** + +### ray/compiler (既存・リファクタ) + +**目的**: DIコンテナのコンパイル + +``` +ray/compiler/ +├── composer.json +├── src/ +│ ├── Compiler.php +│ ├── CompileVisitor.php +│ ├── InstanceScript.php +│ ├── Scripts.php +│ ├── InjectorFactory.php +│ ├── FilePutContents.php +│ ├── CompilerModule.php +│ ├── DiCompileModule.php +│ ├── OverrideLazyModule.php +│ ├── LazyModuleInterface.php +│ ├── Code4Dependency.php +│ ├── Annotation/ +│ │ └── Compile.php +│ └── Exception/ +│ ├── CompileLockFailed.php +│ ├── FileNotWritable.php +│ ├── InvalidInstance.php +│ └── NotCompiled.php +└── src-deprecated/ + └── (後方互換性のため保持) +``` + +**composer.json**: +```json +{ + "name": "ray/compiler", + "description": "Dependency injection compiler for Ray.Di", + "keywords": ["di", "compiler", "codegen"], + "license": "MIT", + "require": { + "php": "^8.2", + "koriym/null-object": "^1.0", + "ray/aop": "^2.18", + "ray/di": "^2.19", + "ray/compiled-injector": "^1.0" + }, + "require-dev": { + "ext-pdo": "*", + "bamarni/composer-bin-plugin": "^1.4", + "phpunit/phpunit": "^11.5" + }, + "autoload": { + "psr-4": { + "Ray\\Compiler\\": ["src", "src-deprecated"] + } + } +} +``` + +サイズ: **約35KB** (本番では不要) + +## アプリケーションでの使用方法 + +### ビルド時 (CI/CD) + +```json +{ + "require": { + "ray/compiled-injector": "^1.0" + }, + "require-dev": { + "ray/compiler": "^2.0" + } +} +``` + +```bash +# 開発依存をインストール +composer install + +# DIコンテナをコンパイル +php bin/compile.php # Compiler使用 + +# 本番用依存のみインストール +composer install --no-dev + +# デプロイ: コンパイル済みスクリプト + CompiledInjectorのみ +``` + +### 実行時 + +```php +use Ray\Compiler\CompiledInjector; + +$injector = new CompiledInjector('/path/to/compiled-scripts'); +$app = $injector->getInstance(App::class); +$app->run(); +``` + +## 実装ステップ + +### Phase 1: 新パッケージ作成 (後方互換性維持) + +1. **新リポジトリ作成**: `ray-di/Ray.CompiledInjector` +2. **ファイル移動**: + ```bash + # Ray.Compilerから以下をコピー + - src/CompiledInjector.php + - src/ScriptInjectorInterface.php + - src/InjectionPoint.php + - src/Types.php + - src/Exception/{ExceptionInterface,ClassNotFound,Unbound,ScriptFileNotFound,ScriptDirNotReadable}.php + - src-function/{singleton,prototype}.php + ``` + +3. **composer.json作成**: 上記の通り + +4. **テスト移動**: + ```bash + # 必要なテストをコピー + - tests/CompiledInjectorTest.php + - tests/ScriptInjectorNullObjectTest.php + - 関連Fakeクラス + ``` + +5. **公開**: Packagistに `ray/compiled-injector` v1.0.0 + +### Phase 2: Ray.Compiler更新 + +1. **Ray.Compilerのcomposer.json更新**: + ```json + { + "require": { + "ray/compiled-injector": "^1.0" + } + } + ``` + +2. **ランタイムファイル削除** (ray/compiled-injectorに移動済み): + ```bash + git rm src/CompiledInjector.php + git rm src/ScriptInjectorInterface.php + git rm src/InjectionPoint.php + # ... 他のランタイムファイル + ``` + +3. **tests更新**: ランタイム関連テストも削除 (compiled-injectorに移動済み) + +4. **リリース**: `ray/compiler` v2.0.0 (破壊的変更だが依存で解決) + +### Phase 3: ドキュメント更新 + +1. **README.md**: 両パッケージの役割を明記 +2. **Migration Guide**: v1からv2への移行手順 +3. **公式ドキュメント**: 使い分けの説明 + +## 後方互換性 + +### 既存ユーザー (ray/compiler v1.x使用中) + +```json +{ + "require": { + "ray/compiler": "^1.13" + } +} +``` + +→ **影響なし**。v1.xは引き続きメンテナンス。 + +### 新規ユーザー / アップグレード + +```json +{ + "require": { + "ray/compiled-injector": "^1.0" + }, + "require-dev": { + "ray/compiler": "^2.0" + } +} +``` + +→ **推奨構成**。セキュリティとサイズの恩恵を受ける。 + +## セキュリティ上の比較 + +### 現状 (ray/compiler v1.x) + +**本番環境に含まれる:** +- ✅ CompiledInjector (必要) +- ❌ Compiler (不要だが含まれる) +- ❌ CompileVisitor (不要だが含まれる) +- ❌ InstanceScript (不要だが含まれる) +- ❌ リフレクション処理 (不要だが含まれる) +- ❌ ファイル書き込み処理 (不要だが含まれる) + +**攻撃面**: 大 + +### 分離後 (ray/compiled-injector + ray/compiler v2.x) + +**本番環境に含まれる:** +- ✅ CompiledInjector (必要) +- ✅ Ray.Di, Ray.Aop (スクリプトが使用) + +**本番環境から除外:** +- ✅ Compiler (devのみ) +- ✅ コンパイル処理全般 (devのみ) + +**攻撃面**: 小 + +## リスクと対策 + +### リスク1: メンテナンスコスト増加 + +**対策**: +- ランタイム部分は安定しており変更頻度が低い +- CIでクロスパッケージテスト + +### リスク2: バージョン管理の複雑化 + +**対策**: +- セマンティックバージョニング厳守 +- compiled-injector はマイナーバージョンのみ +- compiler は新機能時にメジャー更新 + +### リスク3: 移行負担 + +**対策**: +- v1.xは1年間メンテナンス継続 +- 詳細な移行ガイド提供 +- Breaking Changeは明確に文書化 + +## 期待される効果 + +1. **セキュリティ**: ⭐⭐⭐⭐⭐ + - コンパイル処理が本番から完全除外 + +2. **デプロイサイズ**: ⭐⭐⭐ + - 約35KB削減 (全体の約75%削減) + +3. **概念の明確さ**: ⭐⭐⭐⭐⭐ + - ランタイムとビルドツールの分離 + +4. **パフォーマンス**: ⭐ + - ほぼ変わらず (オートロード対象が減る程度) + +5. **複雑性**: ⭐⭐⭐⭐ + - シンプルな分離、依存関係は明確 + +## 結論 + +**実装を推奨します。** + +- ✅ メリットが明確 (セキュリティ、サイズ、明確性) +- ✅ リスクは管理可能 +- ✅ 後方互換性を保てる +- ✅ 概念的にも理にかなっている (TypeScript/tscモデル) + +次のステップ: Phase 1の実装開始 From b35d9c342b0777cff4fa59e73b7dd32b3ea39474 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 2 May 2026 13:36:11 +0000 Subject: [PATCH 2/3] refactor: organize source files into src-compile/ for build-time concerns Move build-time files (Compiler, CompileVisitor, etc.) from src/ to src-compile/ to clarify the separation between runtime and compile-time concerns. Runtime files (CompiledInjector, InjectionPoint, etc.) remain in src/. This is a structural reorganization only: - No namespace changes (Ray\Compiler\* preserved) - No public API changes - Full backward compatibility via PSR-4 multi-path autoload - Sets up future option to extract a ray/compiled-injector package Updates: - 14 files moved to src-compile/ via git mv (history preserved) - composer.json: autoload paths + cs/cs-fix/metrics/phpmd scripts - phpstan.neon, psalm.xml, phpcs.xml: include src-compile Verified: - composer test: 88 tests, 149 assertions PASS - composer cs: PASS - psalm: No errors - phpstan: No errors https://claude.ai/code/session_01QLnL9zQtJ8WAo5HSNBBWhZ --- composer.json | 10 +++++----- phpcs.xml | 1 + phpstan.neon | 1 + psalm.xml | 1 + {src => src-compile}/Annotation/Compile.php | 0 {src => src-compile}/CompileVisitor.php | 0 {src => src-compile}/Compiler.php | 0 {src => src-compile}/CompilerModule.php | 0 {src => src-compile}/DiCompileModule.php | 0 {src => src-compile}/Exception/CompileLockFailed.php | 0 {src => src-compile}/Exception/FileNotWritable.php | 0 {src => src-compile}/Exception/InvalidInstance.php | 0 {src => src-compile}/FilePutContents.php | 0 {src => src-compile}/InjectorFactory.php | 0 {src => src-compile}/InstanceScript.php | 0 {src => src-compile}/LazyModuleInterface.php | 0 {src => src-compile}/OverrideLazyModule.php | 0 {src => src-compile}/Scripts.php | 0 18 files changed, 8 insertions(+), 5 deletions(-) rename {src => src-compile}/Annotation/Compile.php (100%) rename {src => src-compile}/CompileVisitor.php (100%) rename {src => src-compile}/Compiler.php (100%) rename {src => src-compile}/CompilerModule.php (100%) rename {src => src-compile}/DiCompileModule.php (100%) rename {src => src-compile}/Exception/CompileLockFailed.php (100%) rename {src => src-compile}/Exception/FileNotWritable.php (100%) rename {src => src-compile}/Exception/InvalidInstance.php (100%) rename {src => src-compile}/FilePutContents.php (100%) rename {src => src-compile}/InjectorFactory.php (100%) rename {src => src-compile}/InstanceScript.php (100%) rename {src => src-compile}/LazyModuleInterface.php (100%) rename {src => src-compile}/OverrideLazyModule.php (100%) rename {src => src-compile}/Scripts.php (100%) diff --git a/composer.json b/composer.json index 7b42b081..022c2960 100644 --- a/composer.json +++ b/composer.json @@ -29,7 +29,7 @@ }, "autoload": { "psr-4": { - "Ray\\Compiler\\": ["src", "src-deprecated"] + "Ray\\Compiler\\": ["src", "src-compile", "src-deprecated"] }, "files": [ "src-function/prototype.php", @@ -49,12 +49,12 @@ "tests": ["@cs", "@sa", "@test"], "coverage": ["php -dzend_extension=xdebug.so -dxdebug.mode=coverage ./vendor/bin/phpunit --coverage-text --coverage-html=build/coverage"], "pcov": ["php -dextension=pcov.so -d pcov.enabled=1 ./vendor/bin/phpunit --coverage-text --coverage-html=build/coverage --coverage-clover=coverage.xml"], - "cs": ["phpcs --standard=./phpcs.xml src tests"], - "cs-fix": ["phpcbf src src-function tests"], + "cs": ["phpcs --standard=./phpcs.xml src src-compile tests"], + "cs-fix": ["phpcbf src src-compile src-function tests"], "clean": ["phpstan clear-result-cache", "psalm --clear-cache", "rm -rf tests/tmp/*.php"], "sa": ["psalm --show-info=false", "phpstan analyse -c phpstan.neon --no-progress"], - "metrics": ["@test", "phpmetrics --report-html=build/metrics --exclude=Exception --log-junit=build/junit.xml --junit=build/junit.xml src"], - "phpmd": ["phpmd src text ./phpmd.xml"], + "metrics": ["@test", "phpmetrics --report-html=build/metrics --exclude=Exception --log-junit=build/junit.xml --junit=build/junit.xml src src-compile"], + "phpmd": ["phpmd src,src-compile text ./phpmd.xml"], "build": ["@cs", "@sa", "@pcov", "@metrics"] }, "extra": { diff --git a/phpcs.xml b/phpcs.xml index 5e697a32..047f1abc 100755 --- a/phpcs.xml +++ b/phpcs.xml @@ -16,6 +16,7 @@ src + src-compile src-function tests */tests/tmp/* diff --git a/phpstan.neon b/phpstan.neon index 35484ec6..81231f6e 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -2,6 +2,7 @@ parameters: level: 8 paths: - src + - src-compile - tests excludePaths: - tests/tmp/* diff --git a/psalm.xml b/psalm.xml index 94bf1636..69a35bf0 100644 --- a/psalm.xml +++ b/psalm.xml @@ -8,6 +8,7 @@ > + diff --git a/src/Annotation/Compile.php b/src-compile/Annotation/Compile.php similarity index 100% rename from src/Annotation/Compile.php rename to src-compile/Annotation/Compile.php diff --git a/src/CompileVisitor.php b/src-compile/CompileVisitor.php similarity index 100% rename from src/CompileVisitor.php rename to src-compile/CompileVisitor.php diff --git a/src/Compiler.php b/src-compile/Compiler.php similarity index 100% rename from src/Compiler.php rename to src-compile/Compiler.php diff --git a/src/CompilerModule.php b/src-compile/CompilerModule.php similarity index 100% rename from src/CompilerModule.php rename to src-compile/CompilerModule.php diff --git a/src/DiCompileModule.php b/src-compile/DiCompileModule.php similarity index 100% rename from src/DiCompileModule.php rename to src-compile/DiCompileModule.php diff --git a/src/Exception/CompileLockFailed.php b/src-compile/Exception/CompileLockFailed.php similarity index 100% rename from src/Exception/CompileLockFailed.php rename to src-compile/Exception/CompileLockFailed.php diff --git a/src/Exception/FileNotWritable.php b/src-compile/Exception/FileNotWritable.php similarity index 100% rename from src/Exception/FileNotWritable.php rename to src-compile/Exception/FileNotWritable.php diff --git a/src/Exception/InvalidInstance.php b/src-compile/Exception/InvalidInstance.php similarity index 100% rename from src/Exception/InvalidInstance.php rename to src-compile/Exception/InvalidInstance.php diff --git a/src/FilePutContents.php b/src-compile/FilePutContents.php similarity index 100% rename from src/FilePutContents.php rename to src-compile/FilePutContents.php diff --git a/src/InjectorFactory.php b/src-compile/InjectorFactory.php similarity index 100% rename from src/InjectorFactory.php rename to src-compile/InjectorFactory.php diff --git a/src/InstanceScript.php b/src-compile/InstanceScript.php similarity index 100% rename from src/InstanceScript.php rename to src-compile/InstanceScript.php diff --git a/src/LazyModuleInterface.php b/src-compile/LazyModuleInterface.php similarity index 100% rename from src/LazyModuleInterface.php rename to src-compile/LazyModuleInterface.php diff --git a/src/OverrideLazyModule.php b/src-compile/OverrideLazyModule.php similarity index 100% rename from src/OverrideLazyModule.php rename to src-compile/OverrideLazyModule.php diff --git a/src/Scripts.php b/src-compile/Scripts.php similarity index 100% rename from src/Scripts.php rename to src-compile/Scripts.php From 2829c161c88d14af101983e2ca08ed144b87b967 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 3 May 2026 00:40:52 +0000 Subject: [PATCH 3/3] chore: remove SEPARATION_PROPOSAL.md The proposal file was a planning artifact and is no longer needed now that the structural reorganization (src/ vs src-compile/) has been implemented. https://claude.ai/code/session_01QLnL9zQtJ8WAo5HSNBBWhZ --- SEPARATION_PROPOSAL.md | 328 ----------------------------------------- 1 file changed, 328 deletions(-) delete mode 100644 SEPARATION_PROPOSAL.md diff --git a/SEPARATION_PROPOSAL.md b/SEPARATION_PROPOSAL.md deleted file mode 100644 index 913135c0..00000000 --- a/SEPARATION_PROPOSAL.md +++ /dev/null @@ -1,328 +0,0 @@ -# CompiledInjector分離提案 - -## 目的 - -Ray.Compilerから**ランタイム実行部分**(CompiledInjector)を分離し、**ビルドツール部分**(Compiler)と明確に分ける。 - -- ランタイム → `ray/compiled-injector` (本番依存) -- ビルドツール → `ray/compiler` (開発依存) - -## メリット - -1. **セキュリティ向上**: コンパイル処理(リフレクション、ファイル書き込み、コード生成)を本番から除外 -2. **デプロイサイズ削減**: 約35KBのビルドツールを本番から除外 -3. **責務の明確化**: TypeScript/tscと同様の関係性 -4. **依存関係の単純化**: Ray.Di/Aopはそのまま(変更なし) - -## パッケージ構成 - -### ray/compiled-injector (新規) - -**目的**: コンパイル済みスクリプトの実行 - -``` -ray/compiled-injector/ -├── composer.json -├── src/ -│ ├── CompiledInjector.php -│ ├── ScriptInjectorInterface.php -│ ├── InjectionPoint.php -│ ├── Types.php -│ └── Exception/ -│ ├── ExceptionInterface.php -│ ├── ClassNotFound.php -│ ├── Unbound.php -│ ├── ScriptFileNotFound.php -│ └── ScriptDirNotReadable.php -└── src-function/ - ├── singleton.php - └── prototype.php -``` - -**composer.json**: -```json -{ - "name": "ray/compiled-injector", - "description": "Runtime for Ray.Compiler pre-compiled dependency injection scripts", - "keywords": ["di", "runtime"], - "license": "MIT", - "require": { - "php": "^8.2", - "ray/di": "^2.19", - "ray/aop": "^2.18" - }, - "autoload": { - "psr-4": { - "Ray\\Compiler\\": "src" - }, - "files": [ - "src-function/singleton.php", - "src-function/prototype.php" - ] - }, - "suggest": { - "ray/compiler": "Required for compiling DI containers at build time" - } -} -``` - -サイズ: **約11KB** - -### ray/compiler (既存・リファクタ) - -**目的**: DIコンテナのコンパイル - -``` -ray/compiler/ -├── composer.json -├── src/ -│ ├── Compiler.php -│ ├── CompileVisitor.php -│ ├── InstanceScript.php -│ ├── Scripts.php -│ ├── InjectorFactory.php -│ ├── FilePutContents.php -│ ├── CompilerModule.php -│ ├── DiCompileModule.php -│ ├── OverrideLazyModule.php -│ ├── LazyModuleInterface.php -│ ├── Code4Dependency.php -│ ├── Annotation/ -│ │ └── Compile.php -│ └── Exception/ -│ ├── CompileLockFailed.php -│ ├── FileNotWritable.php -│ ├── InvalidInstance.php -│ └── NotCompiled.php -└── src-deprecated/ - └── (後方互換性のため保持) -``` - -**composer.json**: -```json -{ - "name": "ray/compiler", - "description": "Dependency injection compiler for Ray.Di", - "keywords": ["di", "compiler", "codegen"], - "license": "MIT", - "require": { - "php": "^8.2", - "koriym/null-object": "^1.0", - "ray/aop": "^2.18", - "ray/di": "^2.19", - "ray/compiled-injector": "^1.0" - }, - "require-dev": { - "ext-pdo": "*", - "bamarni/composer-bin-plugin": "^1.4", - "phpunit/phpunit": "^11.5" - }, - "autoload": { - "psr-4": { - "Ray\\Compiler\\": ["src", "src-deprecated"] - } - } -} -``` - -サイズ: **約35KB** (本番では不要) - -## アプリケーションでの使用方法 - -### ビルド時 (CI/CD) - -```json -{ - "require": { - "ray/compiled-injector": "^1.0" - }, - "require-dev": { - "ray/compiler": "^2.0" - } -} -``` - -```bash -# 開発依存をインストール -composer install - -# DIコンテナをコンパイル -php bin/compile.php # Compiler使用 - -# 本番用依存のみインストール -composer install --no-dev - -# デプロイ: コンパイル済みスクリプト + CompiledInjectorのみ -``` - -### 実行時 - -```php -use Ray\Compiler\CompiledInjector; - -$injector = new CompiledInjector('/path/to/compiled-scripts'); -$app = $injector->getInstance(App::class); -$app->run(); -``` - -## 実装ステップ - -### Phase 1: 新パッケージ作成 (後方互換性維持) - -1. **新リポジトリ作成**: `ray-di/Ray.CompiledInjector` -2. **ファイル移動**: - ```bash - # Ray.Compilerから以下をコピー - - src/CompiledInjector.php - - src/ScriptInjectorInterface.php - - src/InjectionPoint.php - - src/Types.php - - src/Exception/{ExceptionInterface,ClassNotFound,Unbound,ScriptFileNotFound,ScriptDirNotReadable}.php - - src-function/{singleton,prototype}.php - ``` - -3. **composer.json作成**: 上記の通り - -4. **テスト移動**: - ```bash - # 必要なテストをコピー - - tests/CompiledInjectorTest.php - - tests/ScriptInjectorNullObjectTest.php - - 関連Fakeクラス - ``` - -5. **公開**: Packagistに `ray/compiled-injector` v1.0.0 - -### Phase 2: Ray.Compiler更新 - -1. **Ray.Compilerのcomposer.json更新**: - ```json - { - "require": { - "ray/compiled-injector": "^1.0" - } - } - ``` - -2. **ランタイムファイル削除** (ray/compiled-injectorに移動済み): - ```bash - git rm src/CompiledInjector.php - git rm src/ScriptInjectorInterface.php - git rm src/InjectionPoint.php - # ... 他のランタイムファイル - ``` - -3. **tests更新**: ランタイム関連テストも削除 (compiled-injectorに移動済み) - -4. **リリース**: `ray/compiler` v2.0.0 (破壊的変更だが依存で解決) - -### Phase 3: ドキュメント更新 - -1. **README.md**: 両パッケージの役割を明記 -2. **Migration Guide**: v1からv2への移行手順 -3. **公式ドキュメント**: 使い分けの説明 - -## 後方互換性 - -### 既存ユーザー (ray/compiler v1.x使用中) - -```json -{ - "require": { - "ray/compiler": "^1.13" - } -} -``` - -→ **影響なし**。v1.xは引き続きメンテナンス。 - -### 新規ユーザー / アップグレード - -```json -{ - "require": { - "ray/compiled-injector": "^1.0" - }, - "require-dev": { - "ray/compiler": "^2.0" - } -} -``` - -→ **推奨構成**。セキュリティとサイズの恩恵を受ける。 - -## セキュリティ上の比較 - -### 現状 (ray/compiler v1.x) - -**本番環境に含まれる:** -- ✅ CompiledInjector (必要) -- ❌ Compiler (不要だが含まれる) -- ❌ CompileVisitor (不要だが含まれる) -- ❌ InstanceScript (不要だが含まれる) -- ❌ リフレクション処理 (不要だが含まれる) -- ❌ ファイル書き込み処理 (不要だが含まれる) - -**攻撃面**: 大 - -### 分離後 (ray/compiled-injector + ray/compiler v2.x) - -**本番環境に含まれる:** -- ✅ CompiledInjector (必要) -- ✅ Ray.Di, Ray.Aop (スクリプトが使用) - -**本番環境から除外:** -- ✅ Compiler (devのみ) -- ✅ コンパイル処理全般 (devのみ) - -**攻撃面**: 小 - -## リスクと対策 - -### リスク1: メンテナンスコスト増加 - -**対策**: -- ランタイム部分は安定しており変更頻度が低い -- CIでクロスパッケージテスト - -### リスク2: バージョン管理の複雑化 - -**対策**: -- セマンティックバージョニング厳守 -- compiled-injector はマイナーバージョンのみ -- compiler は新機能時にメジャー更新 - -### リスク3: 移行負担 - -**対策**: -- v1.xは1年間メンテナンス継続 -- 詳細な移行ガイド提供 -- Breaking Changeは明確に文書化 - -## 期待される効果 - -1. **セキュリティ**: ⭐⭐⭐⭐⭐ - - コンパイル処理が本番から完全除外 - -2. **デプロイサイズ**: ⭐⭐⭐ - - 約35KB削減 (全体の約75%削減) - -3. **概念の明確さ**: ⭐⭐⭐⭐⭐ - - ランタイムとビルドツールの分離 - -4. **パフォーマンス**: ⭐ - - ほぼ変わらず (オートロード対象が減る程度) - -5. **複雑性**: ⭐⭐⭐⭐ - - シンプルな分離、依存関係は明確 - -## 結論 - -**実装を推奨します。** - -- ✅ メリットが明確 (セキュリティ、サイズ、明確性) -- ✅ リスクは管理可能 -- ✅ 後方互換性を保てる -- ✅ 概念的にも理にかなっている (TypeScript/tscモデル) - -次のステップ: Phase 1の実装開始