From 0ac4ae6c5ae506a5742a18178db673b347336b87 Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Sat, 20 Aug 2022 00:10:27 +0200 Subject: [PATCH] fix(nuxt): ensure component helper methods do not create side-effects --- packages/nuxt/src/components/loader.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/nuxt/src/components/loader.ts b/packages/nuxt/src/components/loader.ts index 66450ab0709..3dea7db7f49 100644 --- a/packages/nuxt/src/components/loader.ts +++ b/packages/nuxt/src/components/loader.ts @@ -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'] @@ -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