Skip to content

feat(migration): rewrite vitest imports#350

Merged
fengmk2 merged 5 commits intomainfrom
12-16-feat_migration_rewrite_vitest_imports
Dec 24, 2025
Merged

feat(migration): rewrite vitest imports#350
fengmk2 merged 5 commits intomainfrom
12-16-feat_migration_rewrite_vitest_imports

Conversation

@fengmk2
Copy link
Copy Markdown
Member

@fengmk2 fengmk2 commented Dec 17, 2025

Add support for rewriting imports from vite/vitest to @voidzero-dev/vite-plus across an entire project:

  • Add ignore crate dependency for gitignore-aware directory walking
  • Create file_walker.rs module with find_ts_files() function to locate TypeScript/JavaScript files
  • Create import_rewriter.rs module with comprehensive import rewriting rules:
    • vite@voidzero-dev/vite-plus
    • vite/{name}@voidzero-dev/vite-plus/{name}
    • vitest@voidzero-dev/vite-plus/test
    • vitest/config@voidzero-dev/vite-plus
    • vitest/{name}@voidzero-dev/vite-plus/test/{name}
    • @vitest/browser@voidzero-dev/vite-plus/test/browser
    • @vitest/browser/{name}@voidzero-dev/vite-plus/test/browser/{name}
    • @vitest/browser-playwright@voidzero-dev/vite-plus/test/browser-playwright
    • @vitest/browser-playwright/{name}@voidzero-dev/vite-plus/test/browser-playwright/{name}
  • Add rewrite_imports_in_directory() function for batch processing all files
  • Add snap test for vitest migration
  • Update RFC documentation with detailed import rewriting rules

This enables the migration command to automatically rewrite all imports in a project, making it much easier for users to migrate from vite/vitest to vite-plus.


Note

Introduces automated, project-wide import rewriting from vite/vitest (incl. subpaths and @vitest/*) to @voidzero-dev/vite-plus.

  • New: find_ts_files() in vite_migration/file_walker.rs using ignore to respect .gitignore/global/exclude
  • New: import_rewriter.rs with ast-grep rules covering vite, vite/{name}, vitest, vitest/config, vitest/{name}, and @vitest/... → mapped @voidzero-dev/vite-plus equivalents
  • API: Expose rewrite_imports_in_directory() from Rust and NAPI (rewriteImportsInDirectory), plus BatchRewriteResult/BatchRewriteError types; add ignore::Error to vite_error::Error
  • CLI: Migration now runs project-wide rewriting and logs modified files; removes per-file rewrite path; extends package removal to @vitest/browser*
  • Tests/Docs: Add unit tests for walker/rewriter, update snap tests to assert new output, and expand RFC with detailed rewrite rules

Written by Cursor Bugbot for commit 4653d5e. This will update automatically on new commits. Configure here.

@fengmk2 fengmk2 changed the base branch from main to graphite-base/350 December 17, 2025 06:44
@fengmk2 fengmk2 force-pushed the 12-16-feat_migration_rewrite_vitest_imports branch from 91ed166 to 3b16db9 Compare December 17, 2025 06:44
@fengmk2 fengmk2 changed the base branch from graphite-base/350 to 12-16-feat_global_print_versions_includes_global_and_local_cli December 17, 2025 06:44
@fengmk2 fengmk2 force-pushed the 12-16-feat_migration_rewrite_vitest_imports branch from 3b16db9 to 8842612 Compare December 17, 2025 07:41
@fengmk2 fengmk2 force-pushed the 12-16-feat_global_print_versions_includes_global_and_local_cli branch from c6a589b to 8f92600 Compare December 17, 2025 07:52
@fengmk2 fengmk2 force-pushed the 12-16-feat_migration_rewrite_vitest_imports branch 2 times, most recently from 88c168d to f6f9576 Compare December 17, 2025 13:55
@fengmk2 fengmk2 force-pushed the 12-16-feat_global_print_versions_includes_global_and_local_cli branch from 8f92600 to d2e3797 Compare December 19, 2025 00:48
@fengmk2 fengmk2 force-pushed the 12-16-feat_migration_rewrite_vitest_imports branch 2 times, most recently from 9d5a800 to fe4caa0 Compare December 19, 2025 02:27
@fengmk2 fengmk2 force-pushed the 12-16-feat_global_print_versions_includes_global_and_local_cli branch from d2e3797 to 18fa81a Compare December 19, 2025 02:27
@fengmk2 fengmk2 force-pushed the 12-16-feat_migration_rewrite_vitest_imports branch from 90f3ff8 to fda9731 Compare December 22, 2025 01:29
@fengmk2 fengmk2 self-assigned this Dec 22, 2025
@fengmk2 fengmk2 marked this pull request as ready for review December 22, 2025 07:42
@fengmk2 fengmk2 force-pushed the 12-16-feat_migration_rewrite_vitest_imports branch from fda9731 to b24cfe6 Compare December 22, 2025 15:02
@fengmk2 fengmk2 force-pushed the 12-16-feat_global_print_versions_includes_global_and_local_cli branch from 18fa81a to 95db1ed Compare December 22, 2025 15:02
@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented Dec 22, 2025

Deploying vite-plus with  Cloudflare Pages  Cloudflare Pages

Latest commit: 7ea4cc7
Status:⚡️  Build in progress...

View logs

@fengmk2 fengmk2 force-pushed the 12-16-feat_global_print_versions_includes_global_and_local_cli branch from 95db1ed to d781438 Compare December 23, 2025 02:28
@fengmk2 fengmk2 force-pushed the 12-16-feat_migration_rewrite_vitest_imports branch from b24cfe6 to e9087f3 Compare December 23, 2025 02:28
@fengmk2 fengmk2 force-pushed the 12-16-feat_migration_rewrite_vitest_imports branch from e9087f3 to b68fc5e Compare December 23, 2025 08:24
@fengmk2 fengmk2 force-pushed the 12-16-feat_migration_rewrite_vitest_imports branch from 51df143 to be27764 Compare December 23, 2025 11:53
@fengmk2 fengmk2 force-pushed the 12-16-feat_global_print_versions_includes_global_and_local_cli branch 2 times, most recently from 96ffe79 to 7e188bb Compare December 24, 2025 03:30
@fengmk2 fengmk2 force-pushed the 12-16-feat_migration_rewrite_vitest_imports branch from be27764 to 6b51526 Compare December 24, 2025 03:30
@fengmk2 fengmk2 force-pushed the 12-16-feat_global_print_versions_includes_global_and_local_cli branch from 7e188bb to 9c6c683 Compare December 24, 2025 04:38
@fengmk2 fengmk2 force-pushed the 12-16-feat_migration_rewrite_vitest_imports branch from 6b51526 to 08ece1b Compare December 24, 2025 04:38
Comment thread crates/vite_migration/src/vite_config.rs
@fengmk2 fengmk2 force-pushed the 12-16-feat_migration_rewrite_vitest_imports branch from 08ece1b to eb5aeab Compare December 24, 2025 05:25
@fengmk2 fengmk2 force-pushed the 12-16-feat_global_print_versions_includes_global_and_local_cli branch from 9c6c683 to 6a53baa Compare December 24, 2025 05:41
@fengmk2 fengmk2 force-pushed the 12-16-feat_migration_rewrite_vitest_imports branch from eb5aeab to 4653d5e Compare December 24, 2025 05:41
@Brooooooklyn
Copy link
Copy Markdown
Member

cursor review

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no bugs!

@fengmk2 fengmk2 force-pushed the 12-16-feat_migration_rewrite_vitest_imports branch from 4653d5e to a5ed6db Compare December 24, 2025 06:10
@fengmk2 fengmk2 force-pushed the 12-16-feat_global_print_versions_includes_global_and_local_cli branch from 6a53baa to 6fb9939 Compare December 24, 2025 06:10
@graphite-app graphite-app Bot changed the base branch from 12-16-feat_global_print_versions_includes_global_and_local_cli to graphite-base/350 December 24, 2025 06:34
fengmk2 and others added 4 commits December 24, 2025 07:01
Add file walker module and batch rewrite functionality to process all
TypeScript/JavaScript files in a directory while respecting .gitignore rules.

- Add `ignore` crate dependency for gitignore-aware directory walking
- Create `file_walker.rs` module with `find_ts_files()` function
- Add `BatchRewriteResult` struct for tracking modified/unchanged/error files
- Add `rewrite_imports_in_directory()` function for batch processing
- Export new public API: `find_ts_files`, `WalkResult`, `BatchRewriteResult`,
  `rewrite_imports_in_directory`

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Move import rewriting logic from vite_config.rs to import_rewriter.rs
for better separation of concerns:

- vite_config.rs: Now focused only on JSON config merging
- import_rewriter.rs: Handles all import rewriting (vite/vitest → vite-plus)

This makes the codebase more maintainable and the module names more
accurately reflect their responsibilities.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add NAPI bindings for rewrite_imports_in_directory to expose the Rust
batch import rewriting functionality to TypeScript. The migration command
now rewrites vite/vitest imports in all TypeScript/JavaScript files,
not just config files.

Changes:
- Add BatchRewriteResult and BatchRewriteError NAPI structs
- Add rewriteImportsInDirectory NAPI function
- Call rewriteAllImports in both standalone and monorepo migrations
- Display progress showing modified files and any errors

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@fengmk2 fengmk2 force-pushed the 12-16-feat_migration_rewrite_vitest_imports branch from a5ed6db to e7cebaf Compare December 24, 2025 07:01
@graphite-app graphite-app Bot changed the base branch from graphite-base/350 to main December 24, 2025 07:02
…webdriverio

Add rewrite rules for additional vitest browser packages:
- @vitest/browser-preview → @voidzero-dev/vite-plus/test/browser-preview
- @vitest/browser-webdriverio → @voidzero-dev/vite-plus/test/browser-webdriverio

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@fengmk2 fengmk2 force-pushed the 12-16-feat_migration_rewrite_vitest_imports branch from e7cebaf to 7ea4cc7 Compare December 24, 2025 07:02
@fengmk2 fengmk2 merged commit b8bd487 into main Dec 24, 2025
21 of 23 checks passed
Copy link
Copy Markdown
Member Author

fengmk2 commented Dec 24, 2025

Merge activity

@fengmk2 fengmk2 deleted the 12-16-feat_migration_rewrite_vitest_imports branch December 24, 2025 07:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants