mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 13:45:18 +00:00
fix(nuxt): remove backwards-compatible runtimeConfig proxy (#20340)
This commit is contained in:
parent
cd7f38988a
commit
6ef2e1caea
@ -281,30 +281,7 @@ export function createNuxtApp (options: CreateOptions) {
|
||||
|
||||
// Expose runtime config
|
||||
const runtimeConfig = process.server ? options.ssrContext!.runtimeConfig : reactive(nuxtApp.payload.config)
|
||||
|
||||
// TODO: remove in v3.5
|
||||
// Backward compatibility following #4254
|
||||
const compatibilityConfig = new Proxy(runtimeConfig, {
|
||||
get (target, prop: string) {
|
||||
if (prop in target) {
|
||||
return target[prop]
|
||||
}
|
||||
if (process.dev && prop in target.public) {
|
||||
console.warn(`[nuxt] [runtimeConfig] You are trying to access a public runtime config value (\`${prop}\`) directly from the top level. This currently works (for backward compatibility with Nuxt 2) but this compatibility layer will be removed in v3.5. Instead, you can update \`config['${prop}']\` to \`config.public['${prop}']\`.`)
|
||||
}
|
||||
return target.public[prop]
|
||||
},
|
||||
set (target, prop, value) {
|
||||
if (process.server || prop === 'public' || prop === 'app') {
|
||||
return false // Throws TypeError
|
||||
}
|
||||
target[prop] = value
|
||||
target.public[prop] = value
|
||||
return true
|
||||
}
|
||||
})
|
||||
|
||||
nuxtApp.provide('config', compatibilityConfig)
|
||||
nuxtApp.provide('config', runtimeConfig)
|
||||
|
||||
return nuxtApp
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ describe.skipIf(isWindows || process.env.TEST_BUILDER === 'webpack' || process.e
|
||||
|
||||
it('default client bundle size', async () => {
|
||||
stats.client = await analyzeSizes('**/*.js', publicDir)
|
||||
expect(roundToKilobytes(stats.client.totalBytes)).toMatchInlineSnapshot('"94.2k"')
|
||||
expect(roundToKilobytes(stats.client.totalBytes)).toMatchInlineSnapshot('"94.0k"')
|
||||
expect(stats.client.files.map(f => f.replace(/\..*\.js/, '.js'))).toMatchInlineSnapshot(`
|
||||
[
|
||||
"_nuxt/entry.js",
|
||||
@ -45,7 +45,7 @@ describe.skipIf(isWindows || process.env.TEST_BUILDER === 'webpack' || process.e
|
||||
|
||||
it('default server bundle size', async () => {
|
||||
stats.server = await analyzeSizes(['**/*.mjs', '!node_modules'], serverDir)
|
||||
expect(roundToKilobytes(stats.server.totalBytes)).toMatchInlineSnapshot('"66.8k"')
|
||||
expect(roundToKilobytes(stats.server.totalBytes)).toMatchInlineSnapshot('"66.6k"')
|
||||
|
||||
const modules = await analyzeSizes('node_modules/**/*', serverDir)
|
||||
expect(roundToKilobytes(modules.totalBytes)).toMatchInlineSnapshot('"2654k"')
|
||||
|
Loading…
Reference in New Issue
Block a user