mirror of
https://github.com/nuxt/nuxt.git
synced 2025-02-14 12:48:16 +00:00
wip: provide hardcoded check to test delayed hydration runtime comp
This commit is contained in:
parent
66938bc152
commit
20a32b2200
@ -21,7 +21,7 @@ export const loaderPlugin = createUnplugin((options: LoaderOptions) => {
|
|||||||
const exclude = options.transform?.exclude || []
|
const exclude = options.transform?.exclude || []
|
||||||
const include = options.transform?.include || []
|
const include = options.transform?.include || []
|
||||||
const serverComponentRuntime = resolve(distDir, 'components/runtime/server-component')
|
const serverComponentRuntime = resolve(distDir, 'components/runtime/server-component')
|
||||||
|
const clientDelayedComponentRuntime = resolve(distDir, 'components/runtime/client-delayed-component')
|
||||||
return {
|
return {
|
||||||
name: 'nuxt:components-loader',
|
name: 'nuxt:components-loader',
|
||||||
enforce: 'post',
|
enforce: 'post',
|
||||||
@ -72,9 +72,17 @@ export const loaderPlugin = createUnplugin((options: LoaderOptions) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (lazy) {
|
if (lazy) {
|
||||||
imports.add(genImport('vue', [{ name: 'defineAsyncComponent', as: '__defineAsyncComponent' }]))
|
// Temporary hardcoded check to verify runtime functionality
|
||||||
identifier += '_lazy'
|
if (name === "DelayedWrapperTestComponent") {
|
||||||
imports.add(`const ${identifier} = __defineAsyncComponent(${genDynamicImport(component.filePath, { interopDefault: false })}.then(c => c.${component.export ?? 'default'} || c)${isClientOnly ? '.then(c => createClientOnly(c))' : ''})`)
|
imports.add(genImport(clientDelayedComponentRuntime, [{ name: 'createLazyIOClientPage' }]))
|
||||||
|
imports.add(`const ${identifier} = createLazyIOClientPage(${JSON.stringify(name)})`)
|
||||||
|
identifier += '_delayedIO'
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
imports.add(genImport('vue', [{ name: 'defineAsyncComponent', as: '__defineAsyncComponent' }]))
|
||||||
|
identifier += '_lazy'
|
||||||
|
imports.add(`const ${identifier} = __defineAsyncComponent(${genDynamicImport(component.filePath, { interopDefault: false })}.then(c => c.${component.export ?? 'default'} || c)${isClientOnly ? '.then(c => createClientOnly(c))' : ''})`)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
imports.add(genImport(component.filePath, [{ name: component._raw ? 'default' : component.export, as: identifier }]))
|
imports.add(genImport(component.filePath, [{ name: component._raw ? 'default' : component.export, as: identifier }]))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user