vp migrate rewrites catalog: specs in a Bun project whose workspaces.packages is empty

未关闭 适合新手
#3,375 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
76/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
bun, typescript
领域
build-system, cli

调研方向

从 packages/cli/src/migration/migrator/vite-plus-bootstrap.ts 中的 bunWorkspaceDeclaresPackages() 入手,检查它如何处理根 workspaces 字段的数组和对象形式。使用 issue 中的 package.json 和 vp migrate 命令,通过 Bun 1.4.4 重现问题。当根 workspace 字段包含空的 package 列表时,migration 保持 catalog 引用和 overrides 不变,即表示完成。

由索引模型根据 Issue 内容生成。

描述

migration pending triage triage: failed
Describe the bug

In a single-package Bun project that keeps its toolchain in workspaces.catalog with an empty workspaces.packages array, vp migrate handles the project as if it had no catalog support. It replaces every catalog: reference in devDependencies, and the catalog-valued entries in overrides, with concrete versions. workspaces.catalog stays in package.json, but nothing references it anymore.

Bun resolves this setup: bun install succeeds and vite resolves to @voidzero-dev/vite-plus-core. Bun only needs the root package.json to have a workspaces field; without one it fails with catalogs require a "workspaces" field in the root package.json. "workspaces": [] and "workspaces": { "packages": [] } both work.

The check that rejects this setup is bunWorkspaceDeclaresPackages() in packages/cli/src/migration/migrator/vite-plus-bootstrap.ts, which requires a non-empty package list. The comment above it says Bun resolves catalog: references only inside a workspace whose root package.json declares a non-empty workspaces. Bun 1.4.4 does not behave that way.

Reproduction

package.json:

{
  "name": "bun-root-catalog",
  "private": true,
  "type": "module",
  "packageManager": "[email protected]",
  "devDependencies": {
    "@vitest/coverage-v8": "catalog:",
    "vite": "catalog:",
    "vite-plus": "catalog:",
    "vitest": "catalog:"
  },
  "workspaces": {
    "packages": [],
    "catalog": {
      "@vitest/coverage-v8": "5.1.0",
      "vite": "npm:@voidzero-dev/[email protected]",
      "vite-plus": "1.5.0",
      "vitest": "5.1.0"
    }
  },
  "overrides": {
    "vite": "catalog:",
    "vitest": "catalog:"
  }
}
printf 'node_modules\n' > .gitignore
bun install
git init && git add -A && git commit -m init
vp migrate --no-interactive --no-hooks --no-agent --no-editor
git diff package.json

Actual: bun install succeeds before the migration. Afterwards devDependencies become "@vitest/coverage-v8": "5.1.0", "vite": "npm:@voidzero-dev/[email protected]", "vite-plus": "1.5.0" and "vitest": "5.1.0", and overrides become "vite": "npm:@voidzero-dev/[email protected]" and "vitest": "5.1.0". The catalog is left unused.

Expected: no changes. With only "packages": [] changed to "packages": ["packages/*"], and no packages directory at all, the same command prints This project is already using Vite+! Happy coding! and leaves package.json as it is.

Suggested fix

For Bun, treat any root workspaces field (array or object form) as catalog support, which matches the check Bun itself applies, instead of requiring a non-empty package list.

Environment
  • vite-plus 1.5.0 (global and local)
  • Bun 1.4.4
  • Node 26.13.0
  • macOS arm64

Related, but different: #1247 (object-form workspaces, fixed in #1250) and #2309 (vp up rewriting catalog: specs in a monorepo). I have not checked Bun versions older than 1.4.4.

主要语言
TypeScript
星标
6.6k
派生
303
平均合并
1 天 4 小时
30 天内合并 PR
224

环境准备

在 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

更多 TypeScript Issue

把新 issue 发到你的邮箱

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