mirror of
https://github.com/nuxt/nuxt.git
synced 2025-02-28 08:45:31 +00:00
fix: only enable delayed hydration with the experimental flag
This commit is contained in:
parent
e0a2f219db
commit
2f2cb8e0cf
@ -41,13 +41,13 @@ export const loaderPlugin = createUnplugin((options: LoaderOptions) => {
|
|||||||
const imports = new Set<string>()
|
const imports = new Set<string>()
|
||||||
const map = new Map<Component, string>()
|
const map = new Map<Component, string>()
|
||||||
const s = new MagicString(code)
|
const s = new MagicString(code)
|
||||||
|
const nuxt = tryUseNuxt()
|
||||||
// replace `_resolveComponent("...")` to direct import
|
// replace `_resolveComponent("...")` to direct import
|
||||||
s.replace(/(?<=[ (])_?resolveComponent\(\s*["'](lazy-|Lazy)?(Idle|Visible|idle-|visible-)?([^'"]*)["'][^)]*\)/g, (full: string, lazy: string, modifier: string, name: string) => {
|
s.replace(/(?<=[ (])_?resolveComponent\(\s*["'](lazy-|Lazy)?(Idle|Visible|idle-|visible-)?([^'"]*)["'][^)]*\)/g, (full: string, lazy: string, modifier: string, name: string) => {
|
||||||
const component = findComponent(components, name, options.mode)
|
const component = findComponent(components, name, options.mode)
|
||||||
if (component) {
|
if (component) {
|
||||||
// @ts-expect-error TODO: refactor to nuxi
|
// @ts-expect-error TODO: refactor to nuxi
|
||||||
if (component._internal_install && tryUseNuxt()?.options.test === false) {
|
if (component._internal_install && nuxt?.options.test === false) {
|
||||||
// @ts-expect-error TODO: refactor to nuxi
|
// @ts-expect-error TODO: refactor to nuxi
|
||||||
import('../core/features').then(({ installNuxtModule }) => installNuxtModule(component._internal_install))
|
import('../core/features').then(({ installNuxtModule }) => installNuxtModule(component._internal_install))
|
||||||
}
|
}
|
||||||
@ -72,7 +72,7 @@ export const loaderPlugin = createUnplugin((options: LoaderOptions) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (lazy) {
|
if (lazy) {
|
||||||
if (modifier) {
|
if (nuxt?.options.experimental.componentLazyHydration === true && modifier) {
|
||||||
switch (modifier) {
|
switch (modifier) {
|
||||||
case 'Visible':
|
case 'Visible':
|
||||||
case 'visible-':
|
case 'visible-':
|
||||||
|
Loading…
Reference in New Issue
Block a user