Treat gl-emoji as a custom element with the Vue 3 compiler
What does this MR do and why?
With the Vue 3 template compiler, templates that render <gl-emoji> log Failed to resolve component: gl-emoji. The Jest console watcher fails specs on it. In the Vue 2 removal proof of concept !263207, it failed contribution_music_app_spec.js, assignee_dropdown_spec.js and three work item integration specs.
The Vue 3 compiler decides while it parses whether a tag is an element or a component. Two things made it compile gl-emoji as a component:
config/vue3migration/compilers/vue3_template.jsapplied its ownisCustomElementlist only when it compiled, not when it parsed. Webpack runs the wrapper inthread-loader, which drops the function from the loader options (see the comment inconfig/webpack.config.js). So webpack builds with the Vue 3 compiler would also compilegl-emojias a component.jest.config.base.jspassed its own list, which had onlyfe-island-duo-next. !259425 (merged) removed that list, so Jest now relies on the wrapper alone.
This MR has two commits. You can review them one by one:
- The first commit changes the infrastructure (items 1 to 3 below).
- The second commit only changes specs (item 4).
This MR:
- Makes the wrapper parse with its list too, both in
compileand in the exportedparse. A new Vitest spec,spec/frontend/config/vue3migration/compilers/vue3_template_spec.mjs, compiles a template withoutisCustomElementin the options. It fails onmasterand passes here. It also checks that anisCustomElementin the options replaces the wrapper's list. - Makes Jest use the wrapper's list.
- Sets
Vue.config.ignoredElements = ['gl-emoji']in the shared Jest setup, the same ascommons/vue.jsdoes for the app. - Removes the
gl-emojiworkarounds from 29 specs. Those specs find thegl-emojielement instead. The workarounds were:GlEmojistubs, asstubs: ['gl-emoji']or'gl-emoji': true- global
Vue.component('GlEmoji', ...)stand-ins - per-spec
ignoredElementslines
Where the stubs came from
Jest never loads commons/vue.js, so it never set ignoredElements, and Vue 2 warns Unknown custom element: <gl-emoji>. Specs worked around it one by one: some stubbed GlEmoji, starting with emoji_token_spec.js in 2021 and copied since, and others set Vue.config.ignoredElements = ['gl-emoji'] themselves. performance_bar/index_spec.js ignored the Vue 3 warning, with the comment "Setting Vue.config.ignoredElements is not sufficient here for some reason". The reason is the compiler, not the setting. The shared setup and the compiler fix replace all of these.
Screenshots or screen recordings
Not applicable. No build uses the Vue 3 compiler yet, and the app renders gl-emoji the same way.
How to set up and validate locally
- Run
yarn vitest:vue3migration run spec/frontend/config/vue3migration/compilers/vue3_template_spec.mjs. - Run the changed specs with
VUE_VERSION=2, withVUE_VERSION=3, and withVUE_VERSION=3 VUE_COMPILER_VERSION=3. All 30 suites pass in all three, excepthelp_center_spec.jswith the Vue 3 compiler (router-link, see the@gitlab/uifix in References).
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
References
- Found in the Vue 2 removal proof of concept: !263207
router-linkfix in@gitlab/ui: gitlab-org/gitlab-services/design.gitlab.com!6527 (merged)- Vue 3 compiler in the Vue 3 CI jobs, which needs this MR: !263251 (merged)
- Removed the
fe-island-duo-nextelement: !259425 (merged) - Compiler fix found while reviewing this MR, stacked on it: !263534 (merged)
- Plan to remove Vue 2: #634491