mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-23 14:15:13 +00:00
fix(vue-app): reduce consola direct access (#5864)
This commit is contained in:
parent
e4fd6fee7e
commit
0c3b9c5d12
@ -20,7 +20,9 @@ import { createApp, NuxtError } from './index.js'
|
||||
import NuxtLink from './components/nuxt-link.<%= router.prefetchLinks ? "client" : "server" %>.js' // should be included after ./index.js
|
||||
<% if (isDev) { %>import consola from 'consola'<% } %>
|
||||
|
||||
<% if (isDev) { %>consola.wrapConsole()<% } %>
|
||||
<% if (isDev) { %>consola.wrapConsole()
|
||||
console.log = console.__log
|
||||
<% } %>
|
||||
|
||||
// Component: <NuxtLink>
|
||||
Vue.component(NuxtLink.name, NuxtLink)
|
||||
|
@ -1,5 +1,4 @@
|
||||
import { stringify } from 'querystring'
|
||||
import consola from 'consola'
|
||||
import Vue from 'vue'
|
||||
<% if (fetch.server) { %>import fetch from 'node-fetch'<% } %>
|
||||
import middleware from './middleware.js'
|
||||
@ -98,7 +97,7 @@ export default async (ssrContext) => {
|
||||
try {
|
||||
await store.dispatch('nuxtServerInit', app.context)
|
||||
} catch (err) {
|
||||
consola.debug('Error occurred when calling nuxtServerInit: ', err.message)
|
||||
console.debug('Error occurred when calling nuxtServerInit: ', err.message)
|
||||
throw err
|
||||
}
|
||||
}
|
||||
@ -219,7 +218,7 @@ export default async (ssrContext) => {
|
||||
return Promise.all(promises)
|
||||
}))
|
||||
|
||||
<% if (debug) { %>if (asyncDatas.length) consola.debug('Data fetching ' + ssrContext.url + ': ' + (Date.now() - s) + 'ms')<% } %>
|
||||
<% if (debug) { %>if (process.env.DEBUG && asyncDatas.length)console.debug('Data fetching ' + ssrContext.url + ': ' + (Date.now() - s) + 'ms')<% } %>
|
||||
|
||||
// datas are the first row of each
|
||||
ssrContext.nuxt.data = asyncDatas.map(r => r[0] || {})
|
||||
|
@ -3,7 +3,6 @@ import Vuex from 'vuex'
|
||||
|
||||
Vue.use(Vuex)
|
||||
|
||||
const log = console // on server-side, consola will catch all console.log
|
||||
const VUEX_PROPERTIES = ['state', 'getters', 'actions', 'mutations']
|
||||
let store = {}
|
||||
|
||||
@ -16,7 +15,7 @@ void (function updateModules() {
|
||||
// If store is an exported method = classic mode (deprecated)
|
||||
<% if (isDev) { %>
|
||||
if (typeof store === 'function') {
|
||||
return log.warn('Classic mode for store/ is deprecated and will be removed in Nuxt 3.')
|
||||
return console.warn('Classic mode for store/ is deprecated and will be removed in Nuxt 3.')
|
||||
}<% } %>
|
||||
|
||||
// Enforce store modules
|
||||
@ -104,7 +103,7 @@ function normalizeRoot(moduleData, filePath) {
|
||||
|
||||
function normalizeState(moduleData, filePath) {
|
||||
if (typeof moduleData !== 'function') {
|
||||
log.warn(`${filePath} should export a method that returns an object`)
|
||||
console.warn(`${filePath} should export a method that returns an object`)
|
||||
const state = Object.assign({}, moduleData)
|
||||
return () => state
|
||||
}
|
||||
@ -113,7 +112,7 @@ function normalizeState(moduleData, filePath) {
|
||||
|
||||
function normalizeModule(moduleData, filePath) {
|
||||
if (moduleData.state && typeof moduleData.state !== 'function') {
|
||||
log.warn(`'state' should be a method that returns an object in ${filePath}`)
|
||||
console.warn(`'state' should be a method that returns an object in ${filePath}`)
|
||||
const state = Object.assign({}, moduleData.state)
|
||||
// Avoid TypeError: setting a property that has only a getter when overwriting top level keys
|
||||
moduleData = Object.assign({}, moduleData, { state: () => state })
|
||||
|
Loading…
Reference in New Issue
Block a user