mirror of
https://github.com/nuxt/nuxt.git
synced 2025-02-19 23:21:09 +00:00
chore(config): deprecate mode option (#8044)
This commit is contained in:
parent
c9513010eb
commit
d864b2bd75
@ -1,6 +1,6 @@
|
|||||||
import capitalize from 'lodash/capitalize'
|
import capitalize from 'lodash/capitalize'
|
||||||
import env from 'std-env'
|
import env from 'std-env'
|
||||||
import { TARGETS, MODES } from '@nuxt/utils'
|
import { TARGETS } from '@nuxt/utils'
|
||||||
|
|
||||||
export default () => ({
|
export default () => ({
|
||||||
// Env
|
// Env
|
||||||
@ -17,9 +17,10 @@ export default () => ({
|
|||||||
// Rendering
|
// Rendering
|
||||||
ssr: true,
|
ssr: true,
|
||||||
|
|
||||||
// TODO: remove in Nuxt 3
|
// Mode (deprecated)
|
||||||
// Mode
|
mode: undefined,
|
||||||
mode: MODES.universal,
|
|
||||||
|
// Modern
|
||||||
modern: undefined,
|
modern: undefined,
|
||||||
|
|
||||||
// Modules
|
// Modules
|
||||||
|
@ -97,6 +97,18 @@ export function getNuxtConfig (_options) {
|
|||||||
options.target = 'server'
|
options.target = 'server'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Deprecate Mode
|
||||||
|
if (options.mode) {
|
||||||
|
if ((options.mode === MODES.universal && options.ssr) || (options.mode === MODES.spa && !options.ssr)) {
|
||||||
|
consola.warn('`mode` option is deprecated. You can safely remove it from `nuxt.config`')
|
||||||
|
} else {
|
||||||
|
consola.warn('`mode` option is deprecated. Please use `ssr: true` for universal mode or `ssr: false` for spa mode and remove `mode` from `nuxt.config`')
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// For backward compat we need default value
|
||||||
|
options.mode = MODES.universal
|
||||||
|
}
|
||||||
|
|
||||||
// SSR root option
|
// SSR root option
|
||||||
if (options.ssr === false) {
|
if (options.ssr === false) {
|
||||||
options.mode = MODES.spa
|
options.mode = MODES.spa
|
||||||
|
@ -241,7 +241,7 @@ Object {
|
|||||||
"server_error": "Server error",
|
"server_error": "Server error",
|
||||||
"server_error_details": "An error occurred in the application and your page could not be served. If you are the application owner, check your logs for details.",
|
"server_error_details": "An error occurred in the application and your page could not be served. If you are the application owner, check your logs for details.",
|
||||||
},
|
},
|
||||||
"mode": "universal",
|
"mode": undefined,
|
||||||
"modern": undefined,
|
"modern": undefined,
|
||||||
"modes": Object {
|
"modes": Object {
|
||||||
"spa": Object {
|
"spa": Object {
|
||||||
@ -617,7 +617,7 @@ Object {
|
|||||||
"server_error": "Server error",
|
"server_error": "Server error",
|
||||||
"server_error_details": "An error occurred in the application and your page could not be served. If you are the application owner, check your logs for details.",
|
"server_error_details": "An error occurred in the application and your page could not be served. If you are the application owner, check your logs for details.",
|
||||||
},
|
},
|
||||||
"mode": "universal",
|
"mode": undefined,
|
||||||
"modern": undefined,
|
"modern": undefined,
|
||||||
"modes": Object {
|
"modes": Object {
|
||||||
"spa": Object {
|
"spa": Object {
|
||||||
|
1
packages/types/config/index.d.ts
vendored
1
packages/types/config/index.d.ts
vendored
@ -50,6 +50,7 @@ export interface NuxtOptions extends Configuration {
|
|||||||
layoutTransition: Transition
|
layoutTransition: Transition
|
||||||
loading: NuxtOptionsLoading | false | string
|
loading: NuxtOptionsLoading | false | string
|
||||||
loadingIndicator: NuxtOptionsLoadingIndicator | false | string
|
loadingIndicator: NuxtOptionsLoadingIndicator | false | string
|
||||||
|
/** @deprecated Use ssr option instead */
|
||||||
mode: 'spa' | 'universal'
|
mode: 'spa' | 'universal'
|
||||||
target: 'server' | 'static'
|
target: 'server' | 'static'
|
||||||
modern: 'client' | 'server' | boolean
|
modern: 'client' | 'server' | boolean
|
||||||
|
@ -14,10 +14,11 @@ const hooks = [
|
|||||||
|
|
||||||
describe('with-config', () => {
|
describe('with-config', () => {
|
||||||
buildFixture('with-config', () => {
|
buildFixture('with-config', () => {
|
||||||
expect(consola.warn).toHaveBeenCalledTimes(7)
|
expect(consola.warn).toHaveBeenCalledTimes(8)
|
||||||
expect(consola.fatal).toHaveBeenCalledTimes(0)
|
expect(consola.fatal).toHaveBeenCalledTimes(0)
|
||||||
expect(consola.warn.mock.calls).toMatchObject([
|
expect(consola.warn.mock.calls).toMatchObject([
|
||||||
['`router.scrollBehavior` property is deprecated in favor of using `~/app/router.scrollBehavior.js` file, learn more: https://nuxtjs.org/api/configuration-router#scrollbehavior'],
|
['`router.scrollBehavior` property is deprecated in favor of using `~/app/router.scrollBehavior.js` file, learn more: https://nuxtjs.org/api/configuration-router#scrollbehavior'],
|
||||||
|
['`mode` option is deprecated. Please use `ssr: true` for universal mode or `ssr: false` for spa mode and remove `mode` from `nuxt.config`'],
|
||||||
['Unknown mode: unknown. Falling back to universal'],
|
['Unknown mode: unknown. Falling back to universal'],
|
||||||
['Invalid plugin mode (server/client/all): \'abc\'. Falling back to \'all\''],
|
['Invalid plugin mode (server/client/all): \'abc\'. Falling back to \'all\''],
|
||||||
[{
|
[{
|
||||||
|
Loading…
Reference in New Issue
Block a user