fix(nuxt): send the component loader and not the name

This commit is contained in:
julien huang 2024-04-09 21:55:27 +02:00
parent d4bca6cd57
commit b3250e4a46

View File

@ -74,9 +74,10 @@ export const loaderPlugin = createUnplugin((options: LoaderOptions) => {
if (lazy) { if (lazy) {
// Temporary hardcoded check to verify runtime functionality // Temporary hardcoded check to verify runtime functionality
if (name === 'DelayedWrapperTestComponent') { if (name === 'DelayedWrapperTestComponent') {
imports.add(genImport('vue', [{ name: 'defineAsyncComponent', as: '__defineAsyncComponent' }]))
imports.add(genImport(clientDelayedComponentRuntime, [{ name: 'createLazyIOClientPage' }])) imports.add(genImport(clientDelayedComponentRuntime, [{ name: 'createLazyIOClientPage' }]))
identifier += '_delayedIO' identifier += '_delayedIO'
imports.add(`const ${identifier} = createLazyIOClientPage(${JSON.stringify(name)})`) imports.add(`const ${identifier} = createLazyIOClientPage(__defineAsyncComponent(${genDynamicImport(component.filePath)}))`)
} else { } else {
imports.add(genImport('vue', [{ name: 'defineAsyncComponent', as: '__defineAsyncComponent' }])) imports.add(genImport('vue', [{ name: 'defineAsyncComponent', as: '__defineAsyncComponent' }]))
identifier += '_lazy' identifier += '_lazy'