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

Aperta Adatta ai principianti
#993 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
72/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
javascript, node.js
Ambito
backend

Direzione di ricerca

Inizia esaminando normalizePath in @codecov/bundler-plugin-core e i test per i relativi pattern dei nomi dei file Vite. Riproduci la collision con i due percorsi maplibre nell’issue, poi verifica che la normalizzazione preservi il nome completo dell’asset prima dell’hash. Il lavoro è completato quando questi percorsi vengono normalizzati in modo distinto e gli asset invariati non producono più false variazioni di dimensione.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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

Lingua principale
Nessun dato sulla lingua
Stelle
52
Fork
26
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di codecov/feedback

Tutte le issue di codecov/feedback

Issue simili

Altre issue su Backend & API Design

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.