voidzero-dev / voidzero-dev/vite-plus
Build fails when project root is accessed through an NTFS junction
- 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
When the Vite project root is reached through an NTFS junction (directory symlink), `vp build` fails with:
```
[plugin vite:build-html]
error: The "fileName" or "name" properties of emitted chunks and assets must be strings
that are neither absolute nor relative paths, received
"../../../../../../../actual/real/path/to/frontend/index.html"
```
The `vite:build-html` plugin computes the emitted filename for `index.html` as a relative path from the output directory to the input file. When the project is accessed through a junction, the output directory resolves to the **real path** while the input `index.html` stays on the **junction path**. Since these appear to be on different directory trees, the relative path traverses up to the drive root and back down, producing a `../../../..` path that rolldown rejects.
### Reproduction
1. Create a directory junction on Windows:
```powershell
# Real project lives at D:\Projects\my-app\frontend
cmd /c mklink /J D:\Shortcut\Projects D:\Projects
```
2. Run the build from the junction path:
```bash
cd D:\Shortcut\Projects\my-app\frontend
vp build
```
3. The build fails with the error above. Running the same build from the real path (`D:\Projects\my-app\frontend`) succeeds.
### Root cause
Inside the `vite:build-html` plugin's `generateBundle` hook, the emitted filename for `index.html` is computed as a relative path. One side of the calculation uses the resolved/real path and the other uses the junction path. The mismatch produces an invalid relative path.
### Expected behavior
`vp build` should succeed regardless of whether the working directory is reached through a junction or directly. Paths should be consistently resolved (or consistently left unresolved) before computing relative filenames.
### System Info
```
vp v0.1.16
vite v8.0.5
rolldown v1.0.0-rc.13
Node.js v22.22.1
Windows Server 2025 (win32 x64)
pnpm v10.33.0
```
### Used Package Manager
pnpm
### Validations
- [x] Read the [Contributing Guidelines](https://github.com/voidzero-dev/vite-plus/blob/main/CONTRIBUTING.md).
- [x] Check that there isn't [already an issue](https://github.com/voidzero-dev/vite-plus/issues) for the same bug.
- [x] Confirm this is a Vite+ issue and not an upstream issue (Vite, Vitest, tsdown, Rolldown, or Oxc).
- [x] The provided reproduction is a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example).
Hướng dẫn đóng góp
Hướng nghiên cứu
Bắt đầu từ hook generateBundle của plugin vite:build-html, nơi tên tệp được phát ra cho index.html được tính toán, và tái hiện lỗi bằng vp build từ một NTFS junction trên Windows. Theo dõi cách thư mục đầu ra và đường dẫn đầu vào được phân giải; hoàn thành khi bản build thành công từ cả đường dẫn junction lẫn đường dẫn dự án thực, mà không tạo ra tên tệp được phát ra là đường dẫn tuyệt đối hoặc tương đối.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- node.js
- Lĩnh vực
- build-system, tooling
- Loại issue
- Lỗi
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 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
- 48/100