Skip to content

ignore hints no longer ignored with v4.1.0 #9881

@ghiscoding

Description

@ghiscoding

Describe the bug

I have a few lines that I want to ignore and I had some v8 ignore if or v8 ignore next and it was working fine when used with rolldown-vite with Vitest < 4.1 and they no longer work unless I add @preserve but I don't want to since they end up in the minified code.

I'm not sure if has anything to do with PR #9204 but it was working fine with version ^4.0.18, it only regressed with 4.1

I currently have these overrides to use Rolldown-Vite

overrides:
  '@vitest/coverage-v8>vite': npm:rolldown-vite@latest
  '@vitest/ui>vite': npm:rolldown-vite@latest
  vitest>vite: npm:rolldown-vite@latest

I tried to use Vite 8 instead, but that didn't change anything

overrides:
  '@vitest/coverage-v8>vite': ^8.0.0
  '@vitest/ui>vite': ^8.0.0
  vitest>vite: ^8.0.0

Reproduction

For example this simple ignore, is no longer being ignored

function alert(msg) {
  // v8 ignore if
  if (!msg) {
    msg = 'Hello World';
  }
  alert(msg);
}

but if I add @preserve then it is ignored

function alert(msg) {
  // v8 ignore if -- @preserve
  if (!msg) {
    msg = 'Hello World';
  }
  alert(msg);
}

The @preserve wasn't necessary as long as we were adding Rolldown-Vite overrides.

For a full, but very large, repo here is the update to v4.1.0. I used to have 100% coverage with the v8 ignores, but I no longer have 100% with v4.1.0
ghiscoding/slickgrid-universal#2478

System Info

'vitest': 4.1.0
'@vitest/coverage-v8': 4.1.0
'@vitest/ui': 4.1.0
platform: Windows 10

Used Package Manager

pnpm

Validations

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions