mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-25 15:15:19 +00:00
fix(nuxt): clone app config on server (#20278)
This commit is contained in:
parent
8234bc18d7
commit
12f347a928
@ -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",
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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",
|
||||
|
Loading…
Reference in New Issue
Block a user