mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-21 21:25:11 +00:00
perf(nuxt): mark payload as shallowReactive
(#27214)
This commit is contained in:
parent
b3aaa57811
commit
c545c1da5b
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
@ -246,7 +246,7 @@ jobs:
|
||||
TEST_CONTEXT: ${{ matrix.context }}
|
||||
TEST_V4: ${{ matrix.version == 'v4' }}
|
||||
TEST_PAYLOAD: ${{ matrix.payload }}
|
||||
SKIP_BUNDLE_SIZE: ${{ github.event_name != 'push' || matrix.env == 'dev' || matrix.builder == 'webpack' || matrix.context == 'default' || runner.os == 'Windows' }}
|
||||
SKIP_BUNDLE_SIZE: ${{ github.event_name != 'push' || matrix.env == 'dev' || matrix.builder == 'webpack' || matrix.context == 'default' || matrix.payload == 'js' || runner.os == 'Windows' }}
|
||||
|
||||
- uses: codecov/codecov-action@6d798873df2b1b8e5846dba6fb86631229fbcb17 # v4.4.0
|
||||
if: github.event_name != 'push' && matrix.env == 'built' && matrix.builder == 'vite' && matrix.context == 'default' && matrix.os == 'ubuntu-latest' && matrix.manifest == 'manifest-on'
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { effectScope, getCurrentInstance, getCurrentScope, hasInjectionContext, reactive } from 'vue'
|
||||
import { effectScope, getCurrentInstance, getCurrentScope, hasInjectionContext, reactive, shallowReactive } from 'vue'
|
||||
import type { App, EffectScope, Ref, VNode, onErrorCaptured } from 'vue'
|
||||
import type { RouteLocationNormalizedLoaded } from '#vue-router'
|
||||
import type { HookCallback, Hookable } from 'hookable'
|
||||
@ -252,12 +252,11 @@ export function createNuxtApp (options: CreateOptions) {
|
||||
get nuxt () { return __NUXT_VERSION__ },
|
||||
get vue () { return nuxtApp.vueApp.version },
|
||||
},
|
||||
payload: reactive({
|
||||
data: {},
|
||||
state: {},
|
||||
payload: shallowReactive({
|
||||
data: shallowReactive({}),
|
||||
state: reactive({}),
|
||||
once: new Set<string>(),
|
||||
_errors: {},
|
||||
...(import.meta.client ? window.__NUXT__ ?? {} : { serverRendered: true }),
|
||||
_errors: shallowReactive({}),
|
||||
}),
|
||||
static: {
|
||||
data: {},
|
||||
@ -288,11 +287,32 @@ export function createNuxtApp (options: CreateOptions) {
|
||||
}
|
||||
},
|
||||
_asyncDataPromises: {},
|
||||
_asyncData: {},
|
||||
_asyncData: shallowReactive({}),
|
||||
_payloadRevivers: {},
|
||||
...options,
|
||||
} as any as NuxtApp
|
||||
|
||||
if (import.meta.server) {
|
||||
nuxtApp.payload.serverRendered = true
|
||||
}
|
||||
|
||||
// TODO: remove/refactor in https://github.com/nuxt/nuxt/issues/25336
|
||||
if (import.meta.client && window.__NUXT__) {
|
||||
for (const key in window.__NUXT__) {
|
||||
switch (key) {
|
||||
case 'data':
|
||||
case 'state':
|
||||
case '_errors':
|
||||
// Preserve reactivity for non-rich payload support
|
||||
Object.assign(nuxtApp.payload[key], window.__NUXT__[key])
|
||||
break
|
||||
|
||||
default:
|
||||
nuxtApp.payload[key] = window.__NUXT__[key]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nuxtApp.hooks = createHooks<RuntimeNuxtHooks>()
|
||||
nuxtApp.hook = nuxtApp.hooks.hook
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user