mirror of
https://github.com/nuxt/nuxt.git
synced 2025-02-12 03:38:07 +00:00
fix: allow for components to begin with the names of modifiers
This commit is contained in:
parent
cd7e85842c
commit
51f20645d9
@ -44,7 +44,9 @@ export const loaderPlugin = createUnplugin((options: LoaderOptions) => {
|
|||||||
const nuxt = tryUseNuxt()
|
const nuxt = tryUseNuxt()
|
||||||
// replace `_resolveComponent("...")` to direct import
|
// 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) => {
|
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) {
|
if (component) {
|
||||||
// @ts-expect-error TODO: refactor to nuxi
|
// @ts-expect-error TODO: refactor to nuxi
|
||||||
if (component._internal_install && nuxt?.options.test === false) {
|
if (component._internal_install && nuxt?.options.test === false) {
|
||||||
@ -73,7 +75,7 @@ export const loaderPlugin = createUnplugin((options: LoaderOptions) => {
|
|||||||
|
|
||||||
if (lazy) {
|
if (lazy) {
|
||||||
imports.add(genImport('vue', [{ name: 'defineAsyncComponent', as: '__defineAsyncComponent' }]))
|
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) {
|
switch (modifier) {
|
||||||
case 'Visible':
|
case 'Visible':
|
||||||
case 'visible-':
|
case 'visible-':
|
||||||
|
Loading…
Reference in New Issue
Block a user