diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f27fa3e1ef..f89cccc1cf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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' diff --git a/packages/nuxt/src/app/nuxt.ts b/packages/nuxt/src/app/nuxt.ts index 75821e7b55..131be794ed 100644 --- a/packages/nuxt/src/app/nuxt.ts +++ b/packages/nuxt/src/app/nuxt.ts @@ -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(), - _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() nuxtApp.hook = nuxtApp.hooks.hook