Skip to content

Commit 6ec8f44

Browse files
committed
Merge branch 'dev' into 4.0
# Conflicts: # CHANGELOG.md # dist/logger.js # dist/vuex.common.js # dist/vuex.esm.browser.js # dist/vuex.esm.browser.min.js # dist/vuex.esm.js # dist/vuex.js # dist/vuex.min.js # package.json
2 parents 2fbb861 + 7cec79d commit 6ec8f44

File tree

3 files changed

+40
-2
lines changed

3 files changed

+40
-2
lines changed

docs/guide/plugins.md

+17-1
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,17 @@ The plugin will be used by default. For production, you will need [DefinePlugin]
9292
Vuex comes with a logger plugin for common debugging usage:
9393

9494
``` js
95-
import createLogger from 'vuex/dist/logger'
95+
import { createLogger } from 'vuex'
9696

9797
const store = new Vuex.Store({
9898
plugins: [createLogger()]
9999
})
100100
```
101101

102+
:::warning WARNING
103+
Before v3.5.0, the `createLogger` function is exported at `vuex/dist/logger` package. PLease checkout the "Before Vuex v3.5.0" setion of this page.
104+
:::
105+
102106
The `createLogger` function takes a few options:
103107

104108
``` js
@@ -137,3 +141,15 @@ const logger = createLogger({
137141
The logger file can also be included directly via a `<script>` tag, and will expose the `createVuexLogger` function globally.
138142

139143
Note the logger plugin takes state snapshots, so use it only during development.
144+
145+
#### Before Vuex v3.5.0
146+
147+
Before v3.5.0, the `createLogger` function is exported at `vuex/dist/logger` package.
148+
149+
``` js
150+
import createLogger from 'vuex/dist/logger'
151+
152+
const store = new Vuex.Store({
153+
plugins: [createLogger()]
154+
})
155+
```

src/module/module-collection.js

+15-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,21 @@ export default class ModuleCollection {
4949
unregister (path) {
5050
const parent = this.get(path.slice(0, -1))
5151
const key = path[path.length - 1]
52-
if (!parent.getChild(key).runtime) return
52+
const child = parent.getChild(key)
53+
54+
if (!child) {
55+
if (__DEV__) {
56+
console.warn(
57+
`[vuex] trying to unregister module '${key}', which is ` +
58+
`not registered`
59+
)
60+
}
61+
return
62+
}
63+
64+
if (!child.runtime) {
65+
return
66+
}
5367

5468
parent.removeChild(key)
5569
}

test/unit/module/module-collection.spec.js

+8
Original file line numberDiff line numberDiff line change
@@ -92,4 +92,12 @@ describe('ModuleCollection', () => {
9292
collection.unregister(['a'])
9393
expect(collection.get(['a']).state.value).toBe(true)
9494
})
95+
96+
it('warns when unregistering non existing module', () => {
97+
const spy = jest.spyOn(console, 'warn').mockImplementation()
98+
99+
const collection = new ModuleCollection({})
100+
collection.unregister(['a'])
101+
expect(spy).toHaveBeenCalled()
102+
})
95103
})

0 commit comments

Comments
 (0)