Skip to content

Commit 7409d4f

Browse files
ktsnyyx990803
authored andcommitted
fix env check position to avoid possible breakage of current behavior
1 parent fdf4d0f commit 7409d4f

File tree

2 files changed

+25
-18
lines changed

2 files changed

+25
-18
lines changed

src/module/module-collection.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,13 @@ function update (path, targetModule, newModule) {
6666
// update nested modules
6767
if (newModule.modules) {
6868
for (const key in newModule.modules) {
69-
if (
70-
process.env.NODE_ENV !== 'production' &&
71-
!targetModule.getChild(key)
72-
) {
73-
console.warn(
74-
`[vuex] trying to add a new module '${key}' on hot reloading, ` +
75-
'manual reload is needed'
76-
)
69+
if (!targetModule.getChild(key)) {
70+
if (process.env.NODE_ENV !== 'production') {
71+
console.warn(
72+
`[vuex] trying to add a new module '${key}' on hot reloading, ` +
73+
'manual reload is needed'
74+
)
75+
}
7776
return
7877
}
7978
update(

src/store.js

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,10 @@ export class Store {
8181

8282
const mutation = { type, payload }
8383
const entry = this._mutations[type]
84-
if (process.env.NODE_ENV !== 'production' && !entry) {
85-
console.error(`[vuex] unknown mutation type: ${type}`)
84+
if (!entry) {
85+
if (process.env.NODE_ENV !== 'production') {
86+
console.error(`[vuex] unknown mutation type: ${type}`)
87+
}
8688
return
8789
}
8890
this._withCommit(() => {
@@ -111,8 +113,10 @@ export class Store {
111113
} = unifyObjectStyle(_type, _payload)
112114

113115
const entry = this._actions[type]
114-
if (process.env.NODE_ENV !== 'production' && !entry) {
115-
console.error(`[vuex] unknown action type: ${type}`)
116+
if (!entry) {
117+
if (process.env.NODE_ENV !== 'production') {
118+
console.error(`[vuex] unknown action type: ${type}`)
119+
}
116120
return
117121
}
118122
return entry.length > 1
@@ -399,8 +403,10 @@ function registerAction (store, type, handler, local) {
399403
}
400404

401405
function registerGetter (store, type, rawGetter, local) {
402-
if (process.env.NODE_ENV !== 'production' && store._wrappedGetters[type]) {
403-
console.error(`[vuex] duplicate getter key: ${type}`)
406+
if (store._wrappedGetters[type]) {
407+
if (process.env.NODE_ENV !== 'production') {
408+
console.error(`[vuex] duplicate getter key: ${type}`)
409+
}
404410
return
405411
}
406412
store._wrappedGetters[type] = function wrappedGetter (store) {
@@ -442,10 +448,12 @@ function unifyObjectStyle (type, payload, options) {
442448
}
443449

444450
export function install (_Vue) {
445-
if (process.env.NODE_ENV !== 'production' && Vue) {
446-
console.error(
447-
'[vuex] already installed. Vue.use(Vuex) should be called only once.'
448-
)
451+
if (Vue) {
452+
if (process.env.NODE_ENV !== 'production') {
453+
console.error(
454+
'[vuex] already installed. Vue.use(Vuex) should be called only once.'
455+
)
456+
}
449457
return
450458
}
451459
Vue = _Vue

0 commit comments

Comments
 (0)