Skip to content
This repository was archived by the owner on Apr 6, 2023. It is now read-only.

Commit 80abca9

Browse files
authored
fix(nuxt): ensure component helper methods do not create side-effects (#6789)
1 parent ae39a82 commit 80abca9

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

packages/nuxt/src/components/loader.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import MagicString from 'magic-string'
77
import { pascalCase } from 'scule'
88

99
interface LoaderOptions {
10-
getComponents(): Component[]
10+
getComponents (): Component[]
1111
mode: 'server' | 'client'
1212
sourcemap?: boolean
1313
transform?: ComponentsOptions['transform']
@@ -76,11 +76,11 @@ export const loaderPlugin = createUnplugin((options: LoaderOptions) => {
7676
}
7777
if (lazy) {
7878
imports.add(genImport('vue', [{ name: 'defineAsyncComponent', as: '__defineAsyncComponent' }]))
79-
imports.add(`const ${identifier}_lazy = __defineAsyncComponent(${genDynamicImport(component.filePath)})`)
80-
return isClientOnly ? `createClientOnly(${identifier}_lazy)` : `${identifier}_lazy`
79+
imports.add(`const ${identifier}_lazy = /*#__PURE__*/ __defineAsyncComponent(${genDynamicImport(component.filePath)})`)
80+
return isClientOnly ? `/*#__PURE__*/ createClientOnly(${identifier}_lazy)` : `${identifier}_lazy`
8181
} else {
8282
imports.add(genImport(component.filePath, [{ name: component.export, as: identifier }]))
83-
return isClientOnly ? `createClientOnly(${identifier})` : identifier
83+
return isClientOnly ? `/*#__PURE__*/ createClientOnly(${identifier})` : identifier
8484
}
8585
}
8686
// no matched

0 commit comments

Comments
 (0)