mirror of
https://github.com/nuxt/nuxt.git
synced 2025-02-17 06:01:34 +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 env from 'std-env'
|
||||
import { TARGETS, MODES } from '@nuxt/utils'
|
||||
import { TARGETS } from '@nuxt/utils'
|
||||
|
||||
export default () => ({
|
||||
// Env
|
||||
@ -17,9 +17,10 @@ export default () => ({
|
||||
// Rendering
|
||||
ssr: true,
|
||||
|
||||
// TODO: remove in Nuxt 3
|
||||
// Mode
|
||||
mode: MODES.universal,
|
||||
// Mode (deprecated)
|
||||
mode: undefined,
|
||||
|
||||
// Modern
|
||||
modern: undefined,
|
||||
|
||||
// Modules
|
||||
|
@ -97,6 +97,18 @@ export function getNuxtConfig (_options) {
|
||||
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
|
||||
if (options.ssr === false) {
|
||||
options.mode = MODES.spa
|
||||
|
@ -241,7 +241,7 @@ Object {
|
||||
"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.",
|
||||
},
|
||||
"mode": "universal",
|
||||
"mode": undefined,
|
||||
"modern": undefined,
|
||||
"modes": Object {
|
||||
"spa": Object {
|
||||
@ -617,7 +617,7 @@ Object {
|
||||
"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.",
|
||||
},
|
||||
"mode": "universal",
|
||||
"mode": undefined,
|
||||
"modern": undefined,
|
||||
"modes": 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
|
||||
loading: NuxtOptionsLoading | false | string
|
||||
loadingIndicator: NuxtOptionsLoadingIndicator | false | string
|
||||
/** @deprecated Use ssr option instead */
|
||||
mode: 'spa' | 'universal'
|
||||
target: 'server' | 'static'
|
||||
modern: 'client' | 'server' | boolean
|
||||
|
@ -14,10 +14,11 @@ const hooks = [
|
||||
|
||||
describe('with-config', () => {
|
||||
buildFixture('with-config', () => {
|
||||
expect(consola.warn).toHaveBeenCalledTimes(7)
|
||||
expect(consola.warn).toHaveBeenCalledTimes(8)
|
||||
expect(consola.fatal).toHaveBeenCalledTimes(0)
|
||||
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'],
|
||||
['`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'],
|
||||
['Invalid plugin mode (server/client/all): \'abc\'. Falling back to \'all\''],
|
||||
[{
|
||||
|
Loading…
Reference in New Issue
Block a user