Extract shared vue3 infection logic into common module

What does this MR do and why?

The Vite plugin (vite_plugin_vue3_infection.mjs) and Webpack plugin (webpack_vue3_infection_plugin.js) for Vue 3 infection duplicated significant logic:

  • Query string parsing (stripQuery, getQuery, hasVue3Query, hasSpecialQuery)
  • Scanner data loading (loadScannerData)
  • Scanner invocation (runInfectionScanner)
  • Infectability checks (createIsInfectable)
  • Stats reporting (logInfectionStats)
  • appendVue3Query for appending the ?vue3 marker

This MR extracts all shared code into a new config/helpers/vue3_infection_shared.js module so both plugins import from a single source of truth. This reduces the risk of the two implementations drifting apart and makes future changes to the infection logic easier.

What stays in each plugin

  • Vite plugin: The .vue3-infected suffix mechanism (build-mode only), appendVue3Suffix, cleanInfectedId, isVirtualModule, and all Vite plugin hooks.
  • Webpack plugin: rebuildRequest, resolveAliasTargets, applyInfectionResolving (NormalModuleFactory hook taps), applyStatsReporting, and the succeedModule dependency tagging.

Design decisions

The shared createIsInfectable factory accepts two optional callbacks to handle per-bundler differences cleanly:

  • shouldExclude: Returns true for paths that should never be infectable (used by Vite to exclude pre-bundled deps in /tmp/cache/vite/).
  • shouldBypass: Returns true for paths that should bypass the scanner graph lookup and be considered infectable (used by Webpack for loader-injected packages like core-js).

MR acceptance checklist

These checklists encourage us to confirm any changes have been thoroughly considered and tested.

  • This MR does not change existing behavior (refactor only).
  • Vite dev server and build still work correctly with infection enabled.
  • Webpack dev server and build still work correctly with infection enabled. [1607849]

Merge request reports

Loading