mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-23 14:15:13 +00:00
deprecation: Deprecate isServer, isClient and dev
This commit is contained in:
parent
d1ed762c1b
commit
e3974b4729
@ -107,8 +107,6 @@ async function createApp (ssrContext) {
|
||||
|
||||
// Set context to app.context
|
||||
await setContext(app, {
|
||||
isServer: !!ssrContext,
|
||||
isClient: !ssrContext,
|
||||
route,
|
||||
next,
|
||||
error: app.nuxt.error.bind(app),
|
||||
|
@ -102,8 +102,14 @@ export async function setContext(app, context) {
|
||||
// If context not defined, create it
|
||||
if (!app.context) {
|
||||
app.context = {
|
||||
isServer: !!context.isServer,
|
||||
isClient: !!context.isClient,
|
||||
get isServer() {
|
||||
console.warn('context.isServer has been deprecated, please use process.server instead.')
|
||||
return process.server
|
||||
},
|
||||
get isClient() {
|
||||
console.warn('context.isClient has been deprecated, please use process.client instead.')
|
||||
return process.client
|
||||
},
|
||||
isStatic: process.static,
|
||||
isDev: <%= isDev %>,
|
||||
isHMR: false,
|
||||
@ -132,8 +138,8 @@ export async function setContext(app, context) {
|
||||
status: status
|
||||
})
|
||||
}
|
||||
if (app.context.isServer) app.context.beforeNuxtRender = (fn) => context.beforeRenderFns.push(fn)
|
||||
if (app.context.isClient) app.context.nuxtState = window.__NUXT__
|
||||
if (process.server) app.context.beforeNuxtRender = (fn) => context.beforeRenderFns.push(fn)
|
||||
if (process.client) app.context.nuxtState = window.__NUXT__
|
||||
}
|
||||
// Dynamic keys
|
||||
app.context.next = context.next
|
||||
|
@ -129,6 +129,7 @@ export default function webpackClientConfig () {
|
||||
'process.env.VUE_ENV': JSON.stringify('client'),
|
||||
'process.mode': JSON.stringify(this.options.mode),
|
||||
'process.browser': true,
|
||||
'process.client': true,
|
||||
'process.server': false,
|
||||
'process.static': this.isStatic
|
||||
}))
|
||||
@ -220,8 +221,13 @@ export default function webpackClientConfig () {
|
||||
|
||||
// Extend config
|
||||
if (typeof this.options.build.extend === 'function') {
|
||||
const isDev = this.options.dev
|
||||
const extendedConfig = this.options.build.extend.call(this, config, {
|
||||
dev: this.options.dev,
|
||||
get dev () {
|
||||
console.warn('dev has been deprecated into build.extend, please use isDev') // eslint-disable-line no-console
|
||||
return isDev
|
||||
},
|
||||
isDev,
|
||||
isClient: true
|
||||
})
|
||||
// Only overwrite config when something is returned for backwards compatibility
|
||||
|
@ -43,6 +43,7 @@ export default function webpackServerConfig () {
|
||||
'process.env.VUE_ENV': JSON.stringify('server'),
|
||||
'process.mode': JSON.stringify(this.options.mode),
|
||||
'process.browser': false,
|
||||
'process.client': false,
|
||||
'process.server': true,
|
||||
'process.static': this.isStatic
|
||||
}))
|
||||
@ -75,8 +76,13 @@ export default function webpackServerConfig () {
|
||||
|
||||
// Extend config
|
||||
if (typeof this.options.build.extend === 'function') {
|
||||
const isDev = this.options.dev
|
||||
const extendedConfig = this.options.build.extend.call(this, config, {
|
||||
dev: this.options.dev,
|
||||
get dev () {
|
||||
console.warn('dev has been deprecated into build.extend, please use isDev') // eslint-disable-line no-console
|
||||
return isDev
|
||||
},
|
||||
isDev,
|
||||
isServer: true
|
||||
})
|
||||
// Only overwrite config when something is returned for backwards compatibility
|
||||
|
@ -111,7 +111,6 @@ export default class Renderer extends Tapable {
|
||||
await this.applyPluginsAsync('resourcesLoaded', this.resources)
|
||||
|
||||
if (updated.length > 0) {
|
||||
// debug('Updated', updated.join(', '), isServer)
|
||||
this.createRenderer()
|
||||
}
|
||||
}
|
||||
@ -484,7 +483,6 @@ export default class Renderer extends Tapable {
|
||||
|
||||
// Add url and isSever to the context
|
||||
context.url = url
|
||||
context.isServer = true
|
||||
|
||||
// Basic response if SSR is disabled or spa data provided
|
||||
const spa = context.spa || (context.res && context.res.spa)
|
||||
|
Loading…
Reference in New Issue
Block a user