Resolve extensionless package mains before browser-map remaps in the infection scanner

What does this MR do and why?

Fixes a resolver divergence between the vue3-infection scanner and the bundlers it guards.

jszip declares main: './lib/index' (extensionless) and remaps it via the browser field ('./lib/index''./dist/jszip.min.js'). The scanner's main/module resolution only checked for the literal file, so the entry fell through to require.resolve — which ignores the browser field — and the graph recorded lib/index.js while Vite resolves dist/jszip.min.js. Any infected importer of such a package then fails build-vite-prod with File not found in scanner data.

Today no infected module imports jszip, so this is latent on master — it detonates as soon as any island's import graph reaches such a package (found while preparing !247299 (merged), which expands the graph).

The fix resolves main/module with the bundler-style extension attempts and matches browser-map keys against the extensionless spelling too.

Verification

  • New fixture browser_remap_extensionless (jszip-shaped package): the test fails on the unfixed scanner, passes with the fix.
  • yarn vitest:infection-scanner: 109/109.

Merge request reports

Loading
Loading