From 6e78f9dbb03a059814d1284511f732b901dea4f6 Mon Sep 17 00:00:00 2001 From: pooya parsa Date: Tue, 15 Nov 2022 17:27:34 +0100 Subject: [PATCH] fix(nuxt)!: enable payload extraction only for `nuxi generate` (#9018) --- packages/nuxi/src/commands/build.ts | 5 +++++ packages/schema/src/config/experimental.ts | 10 +++++++++- test/fixtures/basic/nuxt.config.ts | 3 ++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/packages/nuxi/src/commands/build.ts b/packages/nuxi/src/commands/build.ts index da19795a5f..9ac44668d8 100644 --- a/packages/nuxi/src/commands/build.ts +++ b/packages/nuxi/src/commands/build.ts @@ -27,6 +27,11 @@ export default defineNuxtCommand({ cwd: rootDir, fileName: args.dotenv }, + defaults: { + experimental: { + payloadExtraction: args.prerender ? true : undefined + } + }, overrides: { _generate: args.prerender } diff --git a/packages/schema/src/config/experimental.ts b/packages/schema/src/config/experimental.ts index df78027ee1..c7096ca04a 100644 --- a/packages/schema/src/config/experimental.ts +++ b/packages/schema/src/config/experimental.ts @@ -77,7 +77,15 @@ export default defineUntypedSchema({ /** * When this option is enabled (by default) payload of pages generated with `nuxt generate` are extracted */ - payloadExtraction: true, + payloadExtraction: { + async $resolve(enabled, get) { + enabled = enabled ?? false + if (enabled) { + console.warn('Using experimental payload extraction for full-static output. You can opt-out by setting `experimental.payloadExtraction` to `false`.') + } + return enabled + } + }, /** Enable cross-origin prefetch using the Speculation Rules API. */ crossOriginPrefetch: false, diff --git a/test/fixtures/basic/nuxt.config.ts b/test/fixtures/basic/nuxt.config.ts index 65664c7d71..b7d6bad0ed 100644 --- a/test/fixtures/basic/nuxt.config.ts +++ b/test/fixtures/basic/nuxt.config.ts @@ -105,7 +105,8 @@ export default defineNuxtConfig({ experimental: { inlineSSRStyles: id => !!id && !id.includes('assets.vue'), reactivityTransform: true, - treeshakeClientOnly: true + treeshakeClientOnly: true, + payloadExtraction: true }, appConfig: { fromNuxtConfig: true,