Skip to content

feat(migration): skip rewriting imports for packages in peerDependencies#367

Merged
fengmk2 merged 2 commits intomainfrom
dont-rewrite-vite-on-peer-deps
Jan 6, 2026
Merged

feat(migration): skip rewriting imports for packages in peerDependencies#367
fengmk2 merged 2 commits intomainfrom
dont-rewrite-vite-on-peer-deps

Conversation

@fengmk2
Copy link
Member

@fengmk2 fengmk2 commented Dec 25, 2025

When a project has vite in peerDependencies (like a Vite plugin), the
import rewriter now skips rewriting vite imports to avoid accidentally
bundling vite-plus into the library.

  • Split AST-grep rules into separate VITE, VITEST, and TSDOWN rule sets
  • Added get_skip_packages_from_root() to check root package.json for peerDependencies
  • Apply rules conditionally based on which packages are in peerDependencies
  • Added comprehensive unit tests for peerDependencies scenarios
  • Added snap test: migration-skip-vite-peer-dependency
  • Updated CLAUDE.md with build and snap-test instructions

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 4.5 noreply@anthropic.com

Copy link
Member Author

fengmk2 commented Dec 25, 2025

@fengmk2 fengmk2 force-pushed the dont-rewrite-vite-on-peer-deps branch 2 times, most recently from ddeb301 to 5bb32a4 Compare December 25, 2025 07:50
@fengmk2 fengmk2 self-assigned this Dec 25, 2025
@fengmk2 fengmk2 force-pushed the dont-rewrite-vite-on-peer-deps branch from 5bb32a4 to 9f1d497 Compare December 25, 2025 08:03
@fengmk2 fengmk2 requested a review from Brooooooklyn December 25, 2025 08:03
@fengmk2 fengmk2 marked this pull request as ready for review December 25, 2025 08:03
Copilot AI review requested due to automatic review settings December 25, 2025 08:03
@fengmk2 fengmk2 changed the title feat(migration): skip rewriting vite imports when vite is in peerDependencies feat(migration): skip rewriting imports for packages in peerDependencies Dec 25, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds intelligent peer dependency handling to the Vite migration tool, preventing accidental bundling of vite-plus into libraries that depend on Vite as a peer dependency (like Vite plugins).

Key Changes:

  • Split monolithic AST-grep rules into separate VITE, VITEST, and TSDOWN rule sets for selective application
  • Implemented package.json peerDependencies detection with per-file resolution
  • Added caching mechanism to optimize package.json reads in monorepos

Reviewed changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated no comments.

Show a summary per file
File Description
crates/vite_migration/src/import_rewriter.rs Core implementation: split AST rules, added SkipPackages logic, implemented nearest package.json resolution, added comprehensive unit tests
packages/global/src/utils/workspace.ts Added node_modules exclusion to workspace package discovery
packages/global/snap-tests/migration-skip-vite-peer-dependency/* Snap test for single-package scenario with vite in peerDependencies
packages/global/snap-tests/migration-monorepo-skip-vite-peer-dependency/* Snap test for monorepo scenario with different peerDependencies per package
ecosystem-ci/repo.json Added vite-plugin-react to ecosystem CI
ecosystem-ci/.gitignore Added vite-plugin-react to gitignore
.github/workflows/e2e-test.yml Added vite-plugin-react E2E test configuration and pull_request trigger
CLAUDE.md Added build and snap-test instructions documentation

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@fengmk2 fengmk2 force-pushed the dont-rewrite-vite-on-peer-deps branch from 9f1d497 to 41f5174 Compare December 26, 2025 06:52
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Dec 26, 2025

Deploying vite-plus with  Cloudflare Pages  Cloudflare Pages

Latest commit: 927dd23
Status:🚫  Build failed.

View logs

@fengmk2 fengmk2 force-pushed the dont-rewrite-vite-on-peer-deps branch from 41f5174 to 8435a43 Compare December 26, 2025 06:56
Copilot AI review requested due to automatic review settings December 26, 2025 06:56
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 24 out of 24 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@fengmk2 fengmk2 mentioned this pull request Dec 27, 2025
@fengmk2 fengmk2 force-pushed the dont-rewrite-vite-on-peer-deps branch from 8435a43 to f663046 Compare January 4, 2026 08:50
Copilot AI review requested due to automatic review settings January 4, 2026 09:06
@fengmk2 fengmk2 force-pushed the dont-rewrite-vite-on-peer-deps branch from f663046 to 33874b2 Compare January 4, 2026 09:06
@fengmk2 fengmk2 mentioned this pull request Jan 4, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 24 out of 24 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@fengmk2 fengmk2 changed the base branch from main to graphite-base/367 January 4, 2026 12:07
@fengmk2 fengmk2 force-pushed the dont-rewrite-vite-on-peer-deps branch from 33874b2 to 6e9016f Compare January 4, 2026 12:07
@fengmk2 fengmk2 changed the base branch from graphite-base/367 to 01-04-test_e2e_skip_rollipop_lint_check January 4, 2026 12:07
@fengmk2 fengmk2 changed the base branch from 01-04-test_e2e_skip_rollipop_lint_check to main January 4, 2026 12:10
@fengmk2 fengmk2 changed the base branch from main to graphite-base/367 January 4, 2026 12:39
@fengmk2 fengmk2 force-pushed the dont-rewrite-vite-on-peer-deps branch from 6e9016f to 6ed5f3a Compare January 4, 2026 12:40
@graphite-app graphite-app bot changed the base branch from graphite-base/367 to main January 4, 2026 12:40
@fengmk2 fengmk2 force-pushed the dont-rewrite-vite-on-peer-deps branch from 6ed5f3a to fdfd022 Compare January 4, 2026 12:40
@fengmk2 fengmk2 changed the base branch from main to graphite-base/367 January 5, 2026 11:14
@fengmk2 fengmk2 force-pushed the dont-rewrite-vite-on-peer-deps branch from fdfd022 to 63f9d5a Compare January 5, 2026 11:14
@fengmk2 fengmk2 force-pushed the graphite-base/367 branch from 4a5de30 to 60194e3 Compare January 5, 2026 11:14
@fengmk2 fengmk2 changed the base branch from graphite-base/367 to merge-json-config-support-jsonc-format January 5, 2026 11:14
@graphite-app graphite-app bot changed the base branch from merge-json-config-support-jsonc-format to main January 5, 2026 11:15
@graphite-app
Copy link

graphite-app bot commented Jan 5, 2026

Merge activity

  • Jan 5, 11:15 AM UTC: Graphite rebased this pull request, because this pull request is set to merge when ready.
  • Jan 6, 2:57 AM UTC: Graphite rebased this pull request, because this pull request is set to merge when ready.
  • Jan 6, 3:09 AM UTC: @fengmk2 merged this pull request with Graphite.

@fengmk2 fengmk2 changed the base branch from main to graphite-base/367 January 5, 2026 11:21
@fengmk2 fengmk2 force-pushed the dont-rewrite-vite-on-peer-deps branch from 63f9d5a to 927dd23 Compare January 5, 2026 11:21
@fengmk2 fengmk2 changed the base branch from graphite-base/367 to merge-json-config-support-jsonc-format January 5, 2026 11:21
@fengmk2 fengmk2 changed the base branch from merge-json-config-support-jsonc-format to graphite-base/367 January 6, 2026 02:57
fengmk2 and others added 2 commits January 6, 2026 02:57
…ndencies

When a project has vite in peerDependencies (like a Vite plugin), the
import rewriter now skips rewriting vite imports to avoid accidentally
bundling vite-plus into the library.

- Split AST-grep rules into separate VITE, VITEST, and TSDOWN rule sets
- Added get_skip_packages_from_root() to check root package.json for peerDependencies
- Apply rules conditionally based on which packages are in peerDependencies
- Added comprehensive unit tests for peerDependencies scenarios
- Added snap test: migration-skip-vite-peer-dependency
- Updated CLAUDE.md with build and snap-test instructions

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Find the nearest package.json for each source file instead of only
checking the root. This allows monorepos to have different packages
with different peerDependencies - a vite plugin package can have vite
in peerDependencies (imports preserved) while an app package without
peerDependencies will have imports rewritten.

- Add find_nearest_package_json() to walk up directories
- Cache package.json lookups for performance
- Add monorepo unit tests and snap-test

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@fengmk2 fengmk2 force-pushed the graphite-base/367 branch from 65ceee6 to 6e4eef6 Compare January 6, 2026 02:57
@fengmk2 fengmk2 force-pushed the dont-rewrite-vite-on-peer-deps branch from 927dd23 to 9a4de13 Compare January 6, 2026 02:57
@graphite-app graphite-app bot changed the base branch from graphite-base/367 to main January 6, 2026 02:57
@fengmk2 fengmk2 merged commit 53b5b52 into main Jan 6, 2026
18 of 20 checks passed
@fengmk2 fengmk2 deleted the dont-rewrite-vite-on-peer-deps branch January 6, 2026 03:09
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.

3 participants