vp migrate crashes with "Undefined meta var" when a migrated config string contains `$`
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
Issue này chưa được đánh giá.
Mô tả
Describe the bug
vp migrate crashes when a config value it merges into vite.config.ts contains $ followed by uppercase letters or digits, for example $200 or $FOO.
■ Fail to parse yaml as Rule.
Error: Fail to parse yaml as Rule.
cause: Error: Undefined meta var `200` used in `fix`.
The crash happens after migration has already deleted eslint.config.mjs and written .oxlintrc.json, so the project is left half-migrated.
It looks like generate_merge_rule in crates/vp_migration/src/vite_config.rs pastes the JSON config text into the ast-grep fix: template, where $NAME and $<digits> are metavariable syntax. Any string value with that shape breaks the rule, for example an ESLint message, an i18n ignore list or a URL with $ in it.
Expected: string values are inserted literally.
I intend to submit a PR for this.
Reproduction
Inline below. It needs three files and no repo.
Steps to reproduce
package.json
{
"name": "vp-migrate-dollar-repro",
"private": true,
"type": "module",
"packageManager": "[email protected]",
"devDependencies": {
"vite": "8.2.2",
"eslint": "10.8.1"
}
}
eslint.config.mjs
export default [
{
rules: {
'no-restricted-imports': ['error', {
paths: [{ name: 'moment', message: 'Use date-fns. moment costs $200 of bundle budget.' }],
}],
},
},
];
vite.config.ts
import { defineConfig } from 'vite';
export default defineConfig({});
git init && git add -A && git commit -m init
pnpm install
pnpm dlx [email protected] vp migrate --no-interactive
git status --porcelain
Result: exit code 1 with the error above. git status shows eslint.config.mjs deleted and .oxlintrc.json untracked. Changing $200 to 200 dollars makes the migration succeed.
System Info
# vp env current: not available, the global vp CLI is not installed (ran through pnpm dlx)
$ pnpm dlx [email protected] vp -V
vp v1.1.0
Local vite-plus:
vite-plus v1.1.0
Tools:
vite v8.3.3
rolldown v1.2.12
vitest v5.0.3
oxfmt v0.72.0
oxlint v1.87.0
oxlint-tsgolint v7.0.2003
macOS 26.6.2 arm64, Node v22.23.2, pnpm 10.14.0
Used Package Manager
pnpm
Logs
■ Fail to parse yaml as Rule.
Error: Fail to parse yaml as Rule.
at mergeAndRemoveJsonConfig (vite-plus/dist/editor-B8tkz7nL.js:9238:17)
code: 'GenericFailure',
cause: Error: Undefined meta var `200` used in `fix`.
at mergeAndRemoveJsonConfig (vite-plus/dist/editor-B8tkz7nL.js:9238:17)
at mergeViteConfigFiles (vite-plus/dist/editor-B8tkz7nL.js:9184:3)
at rewriteMonorepoProject (vite-plus/dist/editor-B8tkz7nL.js:9988:2)
at rewriteRootWorkspacePackageJson (vite-plus/dist/editor-B8tkz7nL.js:7947:2)
at rewriteMonorepo (vite-plus/dist/editor-B8tkz7nL.js:9949:2)
at executeMigrationPlan (vite-plus/dist/migration/bin.js:3860:32)
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.
- Ngôn ngữ chính
- Rust
- Star
- 6k
- Fork
- 274
- Merge trung bình
- 1 ngày 11 giờ
- Pull request đã merge (30 ngày)
- 206
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc 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.
Issue khác của voidzero-dev/vite-plus
-
pending triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
voidzero-dev/vite-plus#2882 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
voidzero-dev/vite-plus#2097 · 10 bình luận · 2 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
`vp dev` does not print "ready in N ms"Có thể đã có người làm @fengmk2 đã nhận 1 ngày trước. Đang mởbug
voidzero-dev/vite-plus#3053 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
the `vp migrate` command wrongly rewrite "vite/rolldown/plugins" to "vite-plus/rolldown/plugins"Đang mởpending triage
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 55/100
voidzero-dev/vite-plus#3050 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Add a dedicated Package Management section with command reference pagesCó thể đã có người làm @jong-kyung đã nhận 1 ngày trước. Đang mởdocumentation
voidzero-dev/vite-plus#3041 · 4 bình luận · 1 reaction · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của voidzero-dev/vite-plus
Issue tương tự
-
agent:triaged bug bughunt pm:bundler priority:p1
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
SocketDev/socket-patch#1573 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
rustix::termios::Termios::OutputModes does not expost some const e.g. OLCUC for musl and macOSĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
bytecodealliance/rustix#1706 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 11 ngày
-
`LazyFrameRemote` and `ExecuteRemote` sinks do not accept `Path`, like `LazyFrame` sinks do.Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
-
Bump anybuf version to ^1.0.0Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
wormhole-foundation/wormhole#5062 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
LaunchOrFocusPlugin switches to the wrong tab after tabs are reordered (tab id used as position)Có thể đã có người làm @olegator888 đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
zellij-org/zellij#5719 ·
Maintainer thường phản hồi trong vòng 1 ngày