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

fix(nuxt): ensure component helper methods do not create side-effects #6789

Merged
merged 1 commit into from
Aug 22, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions packages/nuxt/src/components/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import MagicString from 'magic-string'
import { pascalCase } from 'scule'

interface LoaderOptions {
getComponents(): Component[]
getComponents (): Component[]
mode: 'server' | 'client'
sourcemap?: boolean
transform?: ComponentsOptions['transform']
Expand Down Expand Up @@ -76,11 +76,11 @@ export const loaderPlugin = createUnplugin((options: LoaderOptions) => {
}
if (lazy) {
imports.add(genImport('vue', [{ name: 'defineAsyncComponent', as: '__defineAsyncComponent' }]))
imports.add(`const ${identifier}_lazy = __defineAsyncComponent(${genDynamicImport(component.filePath)})`)
return isClientOnly ? `createClientOnly(${identifier}_lazy)` : `${identifier}_lazy`
imports.add(`const ${identifier}_lazy = /*#__PURE__*/ __defineAsyncComponent(${genDynamicImport(component.filePath)})`)
return isClientOnly ? `/*#__PURE__*/ createClientOnly(${identifier}_lazy)` : `${identifier}_lazy`
} else {
imports.add(genImport(component.filePath, [{ name: component.export, as: identifier }]))
return isClientOnly ? `createClientOnly(${identifier})` : identifier
return isClientOnly ? `/*#__PURE__*/ createClientOnly(${identifier})` : identifier
}
}
// no matched
Expand Down