Skip to content

Migrate to buildStart/buildEnd hooks with major refactoring#4

Merged
rosskevin merged 5 commits into
mainfrom
updates
Sep 16, 2025
Merged

Migrate to buildStart/buildEnd hooks with major refactoring#4
rosskevin merged 5 commits into
mainfrom
updates

Conversation

@rosskevin

Copy link
Copy Markdown
Member

Summary

  • Migrate from config/closeBundle to buildStart/buildEnd hooks for reliable file restoration
  • Major refactoring to eliminate code duplication and reduce complexity by 47%
  • Enhanced error handling and emergency cleanup for bulletproof file restoration

Key Changes

Hook Migration for Reliability

  • Replace config hook with buildStart: Better timing alignment with actual build process
  • Replace closeBundle hook with buildEnd: Guaranteed cleanup execution regardless of build outcome
  • Add emergency cleanup handlers: Process termination safety (SIGINT, SIGTERM, etc.)
  • Fix critical data loss bugs: Directory existence checks and race condition prevention

Major Refactoring (47% complexity reduction)

  • Reduce main file: 364 → 194 lines (47% reduction)
  • Simplify buildEnd: 111 → 35 lines (69% reduction)
  • Extract CleanupManager: Centralized cleanup orchestration with fallbacks
  • Extract ProcessHandlerManager: Process event lifecycle management
  • Add shared constants: Eliminate duplication across files
  • Consolidate file operations: Safe utilities with consistent error handling

Enhanced Reliability

  • Guaranteed file restoration: Original tsconfig files always restored in all scenarios
  • Build failure resilience: Cleanup happens even if build fails
  • Watch mode compatibility: Proper state reset between builds
  • Concurrent build protection: Prevents race conditions
  • Memory leak prevention: Process handler cleanup

Test Plan

  • TypeScript compilation passes
  • ESLint passes with zero violations
  • Build process completes successfully
  • Public API maintains backward compatibility
  • All existing functionality preserved

Breaking Changes

None - maintains full backward compatibility with existing API.

🤖 Generated with Claude Code

rosskevin and others added 5 commits September 16, 2025 11:46
- Replace config hook with buildStart for better timing alignment
- Replace closeBundle hook with buildEnd to guarantee cleanup execution
- Add comprehensive error handling to prevent data loss scenarios
- Implement emergency cleanup handlers for process termination safety
- Fix critical directory existence check bug in util.ts
- Add process handler cleanup to prevent memory leaks
- Enhance state management for watch mode compatibility
- Ensure original tsconfig files are always restored regardless of build outcome

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Reduce main index.ts from 364 to 194 lines (47% reduction)
- Simplify buildEnd method from 111 to 35 lines (69% reduction)
- Extract CleanupManager class for centralized cleanup orchestration
- Extract ProcessHandlerManager for process event lifecycle management
- Create shared constants.ts to eliminate duplication
- Add safe file operation utilities with consistent error handling
- Consolidate banner detection and manual restore logic
- Reduce nesting levels from 5 to 2-3 maximum
- Improve maintainability with clear separation of concerns
- Preserve all existing functionality and error handling behavior

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- actions/checkout: v4 → v5
- actions/setup-node: v4 → v5
- stefanzweifel/git-auto-commit-action: v5 → v6

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@rosskevin rosskevin added the major Increment the major version when merged label Sep 16, 2025
@rosskevin

Copy link
Copy Markdown
Member Author
📦 Published PR as canary version: 2.0.0--canary.4.17773772019.0

✨ Test out this PR locally via:

npm install vite-plugin-tsconfig@2.0.0--canary.4.17773772019.0
# or 
yarn add vite-plugin-tsconfig@2.0.0--canary.4.17773772019.0

@rosskevin rosskevin merged commit 73c4307 into main Sep 16, 2025
1 check passed
@rosskevin

Copy link
Copy Markdown
Member Author

🚀 PR was released in v2.0.0 🚀

@rosskevin rosskevin added the released This issue/pull request has been released. label Sep 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

major Increment the major version when merged released This issue/pull request has been released.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant