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) appendVue3Queryfor appending the?vue3marker
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-infectedsuffix mechanism (build-mode only),appendVue3Suffix,cleanInfectedId,isVirtualModule, and all Vite plugin hooks. - Webpack plugin:
rebuildRequest,resolveAliasTargets,applyInfectionResolving(NormalModuleFactory hook taps),applyStatsReporting, and thesucceedModuledependency tagging.
Design decisions
The shared createIsInfectable factory accepts two optional callbacks to handle per-bundler differences cleanly:
shouldExclude: Returnstruefor paths that should never be infectable (used by Vite to exclude pre-bundled deps in/tmp/cache/vite/).shouldBypass: Returnstruefor paths that should bypass the scanner graph lookup and be considered infectable (used by Webpack for loader-injected packages likecore-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]