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

Open Beginner friendly
#993 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
javascript, node.js
Domain
backend

Research direction

Start by inspecting normalizePath in @codecov/bundler-plugin-core and the tests for its Vite filename patterns. Reproduce the collision with the two maplibre paths in the issue, then check that normalization preserves the full asset name before the hash. Done means those paths normalize distinctly and unchanged assets no longer produce false size changes.

Written by the indexing model from the issue text.

Description

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

Dominant language
No language data
Stars
52
Forks
26
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from codecov/feedback

All issues in codecov/feedback

Similar issues

More Backend & API Design issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.