mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 13:45:18 +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",
|
"h3": "^1.6.4",
|
||||||
"hookable": "^5.5.3",
|
"hookable": "^5.5.3",
|
||||||
"jiti": "^1.18.2",
|
"jiti": "^1.18.2",
|
||||||
|
"klona": "^2.0.6",
|
||||||
"knitwork": "^1.0.0",
|
"knitwork": "^1.0.0",
|
||||||
"local-pkg": "^0.4.3",
|
"local-pkg": "^0.4.3",
|
||||||
"magic-string": "^0.30.0",
|
"magic-string": "^0.30.0",
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { reactive } from 'vue'
|
import { reactive } from 'vue'
|
||||||
|
import { klona } from 'klona'
|
||||||
import type { AppConfig } from 'nuxt/schema'
|
import type { AppConfig } from 'nuxt/schema'
|
||||||
import { useNuxtApp } from './nuxt'
|
import { useNuxtApp } from './nuxt'
|
||||||
// @ts-expect-error virtual file
|
// @ts-expect-error virtual file
|
||||||
@ -37,7 +38,7 @@ function deepAssign (obj: any, newObj: any) {
|
|||||||
export function useAppConfig (): AppConfig {
|
export function useAppConfig (): AppConfig {
|
||||||
const nuxtApp = useNuxtApp()
|
const nuxtApp = useNuxtApp()
|
||||||
if (!nuxtApp._appConfig) {
|
if (!nuxtApp._appConfig) {
|
||||||
nuxtApp._appConfig = reactive(__appConfig) as AppConfig
|
nuxtApp._appConfig = (process.server ? klona(__appConfig) : reactive(__appConfig)) as AppConfig
|
||||||
}
|
}
|
||||||
return nuxtApp._appConfig
|
return nuxtApp._appConfig
|
||||||
}
|
}
|
||||||
|
@ -614,6 +614,9 @@ importers:
|
|||||||
jiti:
|
jiti:
|
||||||
specifier: ^1.18.2
|
specifier: ^1.18.2
|
||||||
version: 1.18.2
|
version: 1.18.2
|
||||||
|
klona:
|
||||||
|
specifier: ^2.0.6
|
||||||
|
version: 2.0.6
|
||||||
knitwork:
|
knitwork:
|
||||||
specifier: ^1.0.0
|
specifier: ^1.0.0
|
||||||
version: 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"')
|
expect(roundToKilobytes(stats.server.totalBytes)).toMatchInlineSnapshot('"92.4k"')
|
||||||
|
|
||||||
const modules = await analyzeSizes('node_modules/**/*', serverDir)
|
const modules = await analyzeSizes('node_modules/**/*', serverDir)
|
||||||
expect(roundToKilobytes(modules.totalBytes)).toMatchInlineSnapshot('"2654k"')
|
expect(roundToKilobytes(modules.totalBytes)).toMatchInlineSnapshot('"2657k"')
|
||||||
|
|
||||||
const packages = modules.files
|
const packages = modules.files
|
||||||
.filter(m => m.endsWith('package.json'))
|
.filter(m => m.endsWith('package.json'))
|
||||||
@ -79,6 +79,7 @@ describe.skipIf(isWindows || process.env.TEST_BUILDER === 'webpack' || process.e
|
|||||||
"h3",
|
"h3",
|
||||||
"hookable",
|
"hookable",
|
||||||
"iron-webcrypto",
|
"iron-webcrypto",
|
||||||
|
"klona",
|
||||||
"node-fetch-native",
|
"node-fetch-native",
|
||||||
"ofetch",
|
"ofetch",
|
||||||
"ohash",
|
"ohash",
|
||||||
|
Loading…
Reference in New Issue
Block a user