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

Commit

Permalink
fix(nuxt): ensure component helper methods do not create side-effects (
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe committed Aug 22, 2022
1 parent ae39a82 commit 80abca9
Showing 1 changed file with 4 additions and 4 deletions.
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

0 comments on commit 80abca9

Please sign in to comment.