Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

`vp create` doesn't rewrite `vite` imports when adding a third-party template to a monorepo

未关闭
#3,281 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

@voidzero-bot 已经在做这个了。

开始于 2026年10月29日。

  • #3282 来自 @voidzero-bot —— 未关闭

评估

难度
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 内容生成。

描述

- P2: has workaround pending triage triage: fix verified
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
主要语言
Rust
星标
6.5k
派生
296
平均合并
1 天 2 小时
30 天内合并 PR
230

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

voidzero-dev/vite-plus 的其他 Issue

查看 voidzero-dev/vite-plus 的全部 Issue

相似的 Issue

更多 Rust Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。