diff --git a/packages/nuxt/package.json b/packages/nuxt/package.json index 0833fea9db..816032be39 100644 --- a/packages/nuxt/package.json +++ b/packages/nuxt/package.json @@ -73,6 +73,7 @@ "h3": "^1.6.4", "hookable": "^5.5.3", "jiti": "^1.18.2", + "klona": "^2.0.6", "knitwork": "^1.0.0", "local-pkg": "^0.4.3", "magic-string": "^0.30.0", diff --git a/packages/nuxt/src/app/config.ts b/packages/nuxt/src/app/config.ts index 68633fcf5a..77efe98805 100644 --- a/packages/nuxt/src/app/config.ts +++ b/packages/nuxt/src/app/config.ts @@ -1,4 +1,5 @@ import { reactive } from 'vue' +import { klona } from 'klona' import type { AppConfig } from 'nuxt/schema' import { useNuxtApp } from './nuxt' // @ts-expect-error virtual file @@ -37,7 +38,7 @@ function deepAssign (obj: any, newObj: any) { export function useAppConfig (): AppConfig { const nuxtApp = useNuxtApp() if (!nuxtApp._appConfig) { - nuxtApp._appConfig = reactive(__appConfig) as AppConfig + nuxtApp._appConfig = (process.server ? klona(__appConfig) : reactive(__appConfig)) as AppConfig } return nuxtApp._appConfig } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b6b4bd15ac..0237169925 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -614,6 +614,9 @@ importers: jiti: specifier: ^1.18.2 version: 1.18.2 + klona: + specifier: ^2.0.6 + version: 2.0.6 knitwork: specifier: ^1.0.0 version: 1.0.0 diff --git a/test/bundle.test.ts b/test/bundle.test.ts index c4dec4c74f..b708de8b61 100644 --- a/test/bundle.test.ts +++ b/test/bundle.test.ts @@ -51,7 +51,7 @@ describe.skipIf(isWindows || process.env.TEST_BUILDER === 'webpack' || process.e expect(roundToKilobytes(stats.server.totalBytes)).toMatchInlineSnapshot('"92.4k"') const modules = await analyzeSizes('node_modules/**/*', serverDir) - expect(roundToKilobytes(modules.totalBytes)).toMatchInlineSnapshot('"2654k"') + expect(roundToKilobytes(modules.totalBytes)).toMatchInlineSnapshot('"2657k"') const packages = modules.files .filter(m => m.endsWith('package.json')) @@ -79,6 +79,7 @@ describe.skipIf(isWindows || process.env.TEST_BUILDER === 'webpack' || process.e "h3", "hookable", "iron-webcrypto", + "klona", "node-fetch-native", "ofetch", "ohash",