Bundle analysis: `normalizePath` replaces everything after the first `-` in a file name, so different assets collide

Đang mở Phù hợp với người mới
#993 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
72/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
javascript, node.js
Lĩnh vực
backend

Hướng nghiên cứu

Bắt đầu bằng cách kiểm tra normalizePath trong @codecov/bundler-plugin-core và các bài kiểm thử cho mẫu tên tệp Vite của nó. Tái hiện xung đột với hai đường dẫn maplibre trong issue, sau đó kiểm tra rằng quá trình chuẩn hóa giữ nguyên toàn bộ tên asset trước hash. Hoàn tất khi các đường dẫn đó được chuẩn hóa khác nhau và các asset không thay đổi không còn tạo ra thay đổi kích thước giả.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Describe the bug

normalizePath in @codecov/bundler-plugin-core replaces everything from the first - in a file name up to the extension with *, not only the hash. If two assets share the text before their first -, they get the same normalized path, and the bundle comparison matches the wrong files against each other.

On https://github.com/kristof-mattei/endless-ssh-rs-with-web/pull/3817#issuecomment-6641294034 (the rows are in the comment's edit history), the bundle report contained these two rows:

Asset Name Size Change Total Size Change (%)
assets/maplibre-*.js -517.19kB 1.85kB -99.64%
assets/maplibre-*.js 517.19kB 519.04kB 27926.19% ⚠️

Both rows come from two unchanged files matched against each other: maplibre-gl-worker-Br3j0JGE.js (519.04 kB) and maplibre-gl-AxBTEyzg.js (1.85 kB). The size changes cancel out exactly. The bundle totals in the same comment are correct.

Environment

  • @codecov/vite-plugin 2.0.1 and @codecov/bundler-plugin-core 2.0.1 (the latest release of both)
  • Vite 8.3.5 with Rolldown 1.2.16, default chunkFileNames and assetFileNames
  • CI on GitHub Actions. Reproduced locally on Node.js 26.13.0

To Reproduce

import { normalizePath } from "@codecov/bundler-plugin-core";

normalizePath("assets/maplibre-gl-AxBTEyzg.js", "assets/[name]-[hash].js", "vite");
// "assets/maplibre-*.js"
normalizePath("assets/maplibre-gl-worker-Br3j0JGE.js", "assets/[name]-[hash][extname]", "vite");
// "assets/maplibre-*.js"
normalizePath("assets/preload-helper-BRbzi6Nc.js", "assets/[name]-[hash].js", "vite");
// "assets/preload-*.js"

Expected behavior

normalizePath replaces only the hash: assets/maplibre-gl-*.js, assets/maplibre-gl-worker-*.js, assets/preload-helper-*.js. If an asset is unchanged, the bundle report lists no size change for it.

Additional context

None at the moment

Ngôn ngữ chính
Không có dữ liệu ngôn ngữ
Star
52
Fork
26
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của codecov/feedback

Tất cả issue của codecov/feedback

Issue tương tự

Thêm issue về Backend & API Design

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.