mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 21:55: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_CONTEXT: ${{ matrix.context }}
|
||||||
TEST_V4: ${{ matrix.version == 'v4' }}
|
TEST_V4: ${{ matrix.version == 'v4' }}
|
||||||
TEST_PAYLOAD: ${{ matrix.payload }}
|
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
|
- 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'
|
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 { App, EffectScope, Ref, VNode, onErrorCaptured } from 'vue'
|
||||||
import type { RouteLocationNormalizedLoaded } from '#vue-router'
|
import type { RouteLocationNormalizedLoaded } from '#vue-router'
|
||||||
import type { HookCallback, Hookable } from 'hookable'
|
import type { HookCallback, Hookable } from 'hookable'
|
||||||
@ -252,12 +252,11 @@ export function createNuxtApp (options: CreateOptions) {
|
|||||||
get nuxt () { return __NUXT_VERSION__ },
|
get nuxt () { return __NUXT_VERSION__ },
|
||||||
get vue () { return nuxtApp.vueApp.version },
|
get vue () { return nuxtApp.vueApp.version },
|
||||||
},
|
},
|
||||||
payload: reactive({
|
payload: shallowReactive({
|
||||||
data: {},
|
data: shallowReactive({}),
|
||||||
state: {},
|
state: reactive({}),
|
||||||
once: new Set<string>(),
|
once: new Set<string>(),
|
||||||
_errors: {},
|
_errors: shallowReactive({}),
|
||||||
...(import.meta.client ? window.__NUXT__ ?? {} : { serverRendered: true }),
|
|
||||||
}),
|
}),
|
||||||
static: {
|
static: {
|
||||||
data: {},
|
data: {},
|
||||||
@ -288,11 +287,32 @@ export function createNuxtApp (options: CreateOptions) {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
_asyncDataPromises: {},
|
_asyncDataPromises: {},
|
||||||
_asyncData: {},
|
_asyncData: shallowReactive({}),
|
||||||
_payloadRevivers: {},
|
_payloadRevivers: {},
|
||||||
...options,
|
...options,
|
||||||
} as any as NuxtApp
|
} 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.hooks = createHooks<RuntimeNuxtHooks>()
|
||||||
nuxtApp.hook = nuxtApp.hooks.hook
|
nuxtApp.hook = nuxtApp.hooks.hook
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user