`vp create` doesn't rewrite `vite` imports when adding a third-party template to a monorepo
维护者通常 1 天内回复
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 35/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 停滞
- 技术栈
- typescript, vite
- 领域
- tooling
调研方向
Read packages/cli/src/migration/migrator/orchestrators.ts and the vp create path in packages/cli/src/create/bin.ts. Compare how rewriteStandaloneProject and rewriteMonorepoProject handle import rewriting and lazy plugin wrapping, then run the reproduction and vp check. Done when creating a package in a monorepo rewrites the vite import to vite-plus and the check passes; a linked pull request is already open.
由索引模型根据 Issue 内容生成。
描述
Describe the bug
When vp create adds a third-party template to an existing Vite+ monorepo, the new package's
vite.config.ts keeps import { defineConfig } from "vite" while lazyPlugins is imported from
vite-plus, so vp check fails on vite-plus/prefer-vite-plus-imports. vp migrate rewrites this
import; vp create doesn't.
Expected: defineConfig is imported from vite-plus, as after vp migrate.
Actual (apps/web/vite.config.ts):
import { sveltekit } from "@sveltejs/kit/vite";
import { defineConfig } from "vite";
import { lazyPlugins } from "vite-plus";
Not framework-specific: adding a React app the same way
(vp create vite --no-interactive -- react-app --template react-ts) gives
import { defineConfig } from "vite" + import { lazyPlugins } from "vite-plus" too.
Outside a monorepo, the same vp create [email protected] … command is correct
(import { defineConfig, lazyPlugins } from "vite-plus"), which points at the monorepo path.
Cause: rewriteMonorepoProject (packages/cli/src/migration/migrator/orchestrators.ts) never calls
rewriteAllImports. rewriteStandaloneProject does, and rewriteMonorepo runs it once for the whole
workspace (it calls rewriteMonorepoProject with deferLazyPluginWrapping = true). vp create adding a
package to a monorepo only calls rewriteMonorepoProject (create/bin.ts), which wraps lazy plugins
without having rewritten imports.
Suggested fix: in rewriteMonorepoProject, when deferLazyPluginWrapping is false, call
rewriteAllImports(projectPath, …) before wrapLazyPluginsInViteConfig, as rewriteStandaloneProject
does. Happy to send a PR if that helps.
Reproduction
https://github.com/DaniilKubarenko/vp-create-monorepo-vite-imports
Steps to reproduce
vp create vite:monorepo --no-interactive --directory repro --no-hooks --package-manager pnpm
cd repro
vp create [email protected] --no-interactive -- web --template minimal --types ts --no-add-ons
cd apps/web
vp check
The linked repo is the unmodified output of the first three commands; `apps/website` and
`packages/utils` are the monorepo template's samples and unrelated.
### System Info
```shell
Node.js:
Version 26.13.0
Source engines.node
Bin Path C:\Users\<user>\AppData\Local\vite-plus\data\js_runtime\node\26.13.0\node.exe
Installed true
Mode managed
Package Manager:
Name pnpm
Version 12.16.1
Source devEngines.packageManager
Installed true
Mode managed
vp v1.4.0
Local vite-plus:
vite-plus v1.4.0
Tools:
vite v8.3.5
rolldown v1.2.15
vitest v5.0.5
oxfmt v0.74.0
oxlint v1.89.0
oxlint-tsgolint v7.0.2004
tsdown v0.23.1
Used Package Manager
pnpm
Logs
x vite-plus(prefer-vite-plus-imports): Use 'vite-plus' instead of 'vite' in Vite+ projects.
,-[vite.config.ts:3:30]
2 | import { sveltekit } from "@sveltejs/kit/vite";
3 | import { defineConfig } from "vite";
: ^^^^^^
Validations
- Read the Contributing Guidelines.
- Check that there isn't already an issue for the same bug.
- Confirm this is a Vite+ issue and not an upstream issue (Vite, Vitest, tsdown, Rolldown, or Oxc).
- The provided reproduction is a minimal reproducible example.
- 主要语言
- Rust
- 星标
- 6.5k
- 派生
- 296
- 平均合并
- 1 天 2 小时
- 30 天内合并 PR
- 230
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
voidzero-dev/vite-plus 的其他 Issue
-
pending triage
难度 2/5 1-3 小时 新手友好度 63/100
voidzero-dev/vite-plus#3235 ·
维护者通常 1 天内回复
-
Docker guide: the runtime stage needs libatomic1 for Node.js 25 and later可能已有人在做 @kshanxs 于 5 天前认领。 未关闭documentation
难度 2/5 1-3 小时 新手友好度 84/100
voidzero-dev/vite-plus#3219 · 2 条评论 · 1 个 reaction ·
维护者通常 1 天内回复
-
pending triage
难度 2/5 1-3 小时 新手友好度 72/100
voidzero-dev/vite-plus#2882 · 2 条评论 ·
维护者通常 1 天内回复
-
`npm install -g` keeps the `bin` link on the old version after the default Node.js changes可能已有人在做 @mondaychen 今天认领。 未关闭bug triage: failed
voidzero-dev/vite-plus#3279 · 1 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
-
triage: not actionable
难度 5/5 一周以上 新手友好度 15/100
voidzero-dev/vite-plus#3277 · 1 条评论 · 3 个 reaction ·
维护者通常 1 天内回复
查看 voidzero-dev/vite-plus 的全部 Issue
相似的 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 83/100
维护者通常 1 天内回复
-
o8 next debug build aborts on Glass to Dark appearance switch (nil identifier messaged before check)未关闭bug
难度 2/5 1-3 小时 新手友好度 78/100
hurttlocker/o8#5112 ·
-
难度 2/5 1-3 小时 新手友好度 79/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
memory_patch_page drops the `#` of headings like `## Notes on C#`可能已有人在做 @viniciusdsandrade 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 85/100
akitaonrails/ai-memory#1859 ·
维护者通常 1 天内回复