voidzero-dev / voidzero-dev/vite-plus
defineConfig always injects vite-plus:vitest-resolver into vp build / vp dev even when Vitest isn't used
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Rust
- Star
- 5.8k
- Fork
- 262
- Merge trung bình
- 23 giờ 18 phút
- Pull request đã merge (30 ngày)
- 139
Mô tả
Describe the bug
defineConfig from vite-plus always prepends Vitest-only plugins into every Vite config, including for vp build / vp dev:
vite-plus:vitest-resolvervite-plus:auto-inline-matchervite-plus:coverage-version-guard
Projects that use Vite+ for toolchain (fmt / lint / build) but run tests with another runner (e.g. Bun's bun:test) still pay for these plugins on every production build.
Rolldown/Vite plugin timings report:
[PLUGIN_TIMINGS] Your build spent significant time in plugins. Here is a breakdown:
- vite-plus:vitest-resolver (87%)
The resolver is an enforce: "pre" resolveId hook, so it runs on every module resolve. It early-returns for non-vitest / @vitest/* ids, but with a large graph that still dominates plugin time.
There is no documented opt-out. lazyPlugins only gates user plugins during config-metadata loads; it does not skip these injected plugins on build/dev. vite-plus/prefer-vite-plus-imports also pushes app configs to import defineConfig from vite-plus rather than vite, so switching away isn't a clean escape hatch.
Reproduction
- Use
import { defineConfig } from "vite-plus"in an appvite.config.ts - Do not configure or run
vp test/ Vitest - Run
vp build(with plugin timings enabled) - Observe
vite-plus:vitest-resolvernear the top of[PLUGIN_TIMINGS]
Expected
Vitest helper plugins should only be injected when running tests (vp test / Vitest), or there should be an explicit opt-out for projects that don't use Vitest.
System Info
vite-plus:0.2.5- Tests: Bun (
bun:test), not Vitest - Apps build via
vp build
Suggested fix
- Gate injection on test command / presence of
testconfig, or - Add a config flag such as
test: false/vitest: falseto skip injection, or - Document a supported way to opt out without fighting
prefer-vite-plus-imports
Related
- Implementation that introduced/patched the resolver: https://github.com/voidzero-dev/vite-plus/pull/356
- Auto-inline matcher: https://github.com/voidzero-dev/vite-plus/pull/1113
lazyPlugins(user plugins only): https://github.com/voidzero-dev/vite-plus/pull/1215
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Tái hiện vấn đề với một vite.config.ts import defineConfig từ vite-plus và chạy vp build khi đã bật thời gian của plugin. Đọc các thay đổi đối với resolver và auto-inline matcher trong các PR 356 và 1113, sau đó theo dõi cách vp build, vp dev và vp test đưa chúng vào; hoàn thành có nghĩa là các lệnh không phải lệnh test không còn phát sinh các plugin chỉ dành cho Vitest hoặc có một tùy chọn opt-out được lập tài liệu.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- bun, typescript
- Lĩnh vực
- build-system, tooling
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Ít trao đổi
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 52/100