Align Vite and webpack Vue 3 alias resolution
Note
Stacked on !251351 (merged). Review that one first; this MR's diff is only the plugin change.
What this does
Vite runs its alias plugin before user plugins that declare enforce: 'pre'. A CONTEXT_ALIASES key that a global alias also matches therefore arrives at resolveId already expanded to an absolute path, so the exact string match at config/helpers/vite_plugin_vue3_infection.mjs:108 fails and the redirect is skipped.
Webpack is unaffected. Its beforeResolve hook runs before resolution and still sees the raw specifier.
The consequence is that the same page can run different code locally and in CI. That is how the vue-virtual-scroller crash fixed in !251351 (merged) reached CI while being impossible to reproduce in GDK, and it would hide the next one just as well.
vendor/vue-virtual-scroller was the only shadowed key, because vendor is a global prefix alias (config/helpers/aliases.js:13). Verified against the dev server: vuedraggable correctly redirected to @gitlab/vuedraggable-vue3/...?vue3, while the scroller resolved to the plain copy with no ?vue3 query at all.
The change
applyAliasList moves into config/helpers/vue3_infection_shared.js, where it can be unit tested. At configResolved the plugin expands every CONTEXT_ALIASES key through config.resolve.alias and records the expanded form, then matches on it as well as the raw key.
This generalises the existing one-off workaround for the vue specifier at lines 100-105, rather than adding a second special case beside it.
Risk
Low, and deliberately so. After !251351 (merged) no CONTEXT_ALIASES key is shadowed by a global alias, so this changes no current resolution. It is a guard against the next one.
That is also why the two changes are separate, and why this one is second. Landing it before !251351 (merged) would make the scroller crash reproduce in GDK as well as CI, rather than fixing it.
Verification
yarn vitest run --config vitest.infection_scanner.config.mjs — 131 tests, 0 failures, including 7 new cases covering prefix expansion, regular expression aliases, first-match-wins ordering, and the partial-segment case that must not match.
Re-verified in GDK after rebasing onto current master (!251351 (merged) merged):
- Set
vite.vue_version: 3ingdk.ymland restart Vite. Local GDK builds Vue 2 by default, so the alias-resolution path only runs under a real Vue 3 build. - Enable the
vue3_migrate_project_overviewfeature flag. - Visit a project overview page, for example
flightjs/Flight. - Confirm the browser console logs
Using Vue.js 3 (with @vue/compat)for each mounted app (RepositoryAppRoot,FileTreeBrowserRoot,RepositoryLastCommitRoot,TooltipsRoot,InviteMembersModalRoot) with no errors, and the page renders fully.
![]() |
References
- Part of #619357 (closed)
- Stacked on !251351 (merged)
