diff --git a/packages/nuxt/src/core/runtime/nitro/renderer.ts b/packages/nuxt/src/core/runtime/nitro/renderer.ts index 60cffdf21d30..3cc1bc37c4ee 100644 --- a/packages/nuxt/src/core/runtime/nitro/renderer.ts +++ b/packages/nuxt/src/core/runtime/nitro/renderer.ts @@ -126,6 +126,7 @@ const getSPARenderer = lazyCachedFunction(async () => { const renderToString = (ssrContext: NuxtSSRContext) => { const config = useRuntimeConfig() + ssrContext.modules = ssrContext.modules || new Set() ssrContext!.payload = { _errors: {}, serverRendered: false, diff --git a/test/basic.test.ts b/test/basic.test.ts index 73a8292ba9f9..08597534ed42 100644 --- a/test/basic.test.ts +++ b/test/basic.test.ts @@ -1169,6 +1169,17 @@ describe.skipIf(isDev() || isWebpack)('inlining component styles', () => { } }) + it('should inline global css when accessing a page with `ssr: false` override via route rules', async () => { + const globalCSS = [ + '{--plugin:"plugin"}', // CSS imported ambiently in JS/TS + '{--global:"global";' // global css from nuxt.config + ] + const html = await $fetch('/route-rules/spa') + for (const style of globalCSS) { + expect(html).toContain(style) + } + }) + it('should not include inlined CSS in generated CSS file', async () => { const html: string = await $fetch('/styles') const cssFiles = new Set([...html.matchAll(/]*href="([^"]*\.css)">/g)].map(m => m[1])) diff --git a/test/bundle.test.ts b/test/bundle.test.ts index 571b5a39a6cd..44c7643a6691 100644 --- a/test/bundle.test.ts +++ b/test/bundle.test.ts @@ -35,7 +35,7 @@ describe.skipIf(process.env.SKIP_BUNDLE_SIZE === 'true' || process.env.ECOSYSTEM it('default server bundle size', async () => { stats.server = await analyzeSizes(['**/*.mjs', '!node_modules'], serverDir) - expect.soft(roundToKilobytes(stats.server.totalBytes)).toMatchInlineSnapshot('"63.9k"') + expect.soft(roundToKilobytes(stats.server.totalBytes)).toMatchInlineSnapshot('"64.0k"') const modules = await analyzeSizes('node_modules/**/*', serverDir) expect.soft(roundToKilobytes(modules.totalBytes)).toMatchInlineSnapshot('"2328k"')