mirror of
https://github.com/nuxt/nuxt.git
synced 2025-02-22 16:39:58 +00:00
fix(nuxt): ensure component helper methods do not create side-effects (#6789)
This commit is contained in:
parent
ae39a821b5
commit
80abca9d2a
@ -76,11 +76,11 @@ 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' }]))
|
||||||
imports.add(`const ${identifier}_lazy = __defineAsyncComponent(${genDynamicImport(component.filePath)})`)
|
imports.add(`const ${identifier}_lazy = /*#__PURE__*/ __defineAsyncComponent(${genDynamicImport(component.filePath)})`)
|
||||||
return isClientOnly ? `createClientOnly(${identifier}_lazy)` : `${identifier}_lazy`
|
return isClientOnly ? `/*#__PURE__*/ createClientOnly(${identifier}_lazy)` : `${identifier}_lazy`
|
||||||
} else {
|
} else {
|
||||||
imports.add(genImport(component.filePath, [{ name: component.export, as: identifier }]))
|
imports.add(genImport(component.filePath, [{ name: component.export, as: identifier }]))
|
||||||
return isClientOnly ? `createClientOnly(${identifier})` : identifier
|
return isClientOnly ? `/*#__PURE__*/ createClientOnly(${identifier})` : identifier
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// no matched
|
// no matched
|
||||||
|
Loading…
Reference in New Issue
Block a user