Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

fix(nuxt)!: enable payload extraction only for nuxi generate #9018

Merged
merged 2 commits into from Nov 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/nuxi/src/commands/build.ts
Expand Up @@ -27,6 +27,11 @@ export default defineNuxtCommand({
cwd: rootDir,
fileName: args.dotenv
},
defaults: {
experimental: {
payloadExtraction: args.prerender ? true : undefined
}
},
overrides: {
_generate: args.prerender
}
Expand Down
10 changes: 9 additions & 1 deletion packages/schema/src/config/experimental.ts
Expand Up @@ -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) {
pi0 marked this conversation as resolved.
Show resolved Hide resolved
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,
Expand Down
3 changes: 2 additions & 1 deletion test/fixtures/basic/nuxt.config.ts
Expand Up @@ -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,
Expand Down