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

オープン 初心者向け
#993 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
72/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
javascript, node.js
領域
backend

調査の方向性

まず、@codecov/bundler-plugin-core の normalizePath と、その Vite ファイル名パターンのテストを調べます。issue にある 2 つの maplibre パスで衝突を再現し、正規化によってハッシュより前のアセット名全体が保持されることを確認します。これらのパスが異なる形に正規化され、変更されていないアセットで誤ったサイズ変更が発生しなくなれば完了です。

索引モデルが issue の本文から書いたものです。

説明

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

主要言語
言語のデータがありません
スター
52
フォーク
26
PR マージ指標
30日以内にマージされた PR はありません

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

codecov/feedback のほかの issue

codecov/feedback の issue をすべて見る

似ている issue

Backend & API Design の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。