fix: allow for components to begin with the names of modifiers

This commit is contained in:
Michael Brevard 2024-06-17 23:00:16 +03:00 committed by GitHub
parent cd7e85842c
commit 51f20645d9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -44,7 +44,9 @@ export const loaderPlugin = createUnplugin((options: LoaderOptions) => {
const nuxt = tryUseNuxt()
// replace `_resolveComponent("...")` to direct import
s.replace(/(?<=[ (])_?resolveComponent\(\s*["'](lazy-|Lazy)?(Idle|Visible|idle-|visible-|Event|event-)?([^'"]*)["'][^)]*\)/g, (full: string, lazy: string, modifier: string, name: string) => {
const component = findComponent(components, name, options.mode)
const normalComponent = findComponent(components, name, options.mode)
const modifierComponent = !normalComponent && modifier ? findComponent(components, modifier + name, options.mode) : null
const component = normalComponent || modifierComponent
if (component) {
// @ts-expect-error TODO: refactor to nuxi
if (component._internal_install && nuxt?.options.test === false) {
@ -73,7 +75,7 @@ export const loaderPlugin = createUnplugin((options: LoaderOptions) => {
if (lazy) {
imports.add(genImport('vue', [{ name: 'defineAsyncComponent', as: '__defineAsyncComponent' }]))
if (nuxt?.options.experimental.delayedHydration === true && modifier) {
if (modifier && normalComponent && nuxt?.options.experimental.delayedHydration === true) {
switch (modifier) {
case 'Visible':
case 'visible-':