Skip to content

fix(vue2): Remove throwing error on inspect missing vuex module #2095

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions packages/app-backend-vue2/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ export function setupPlugin (api: DevtoolsApi, app: App, Vue) {
if (payload.inspectorId === VUEX_INSPECTOR_ID) {
const modulePath = payload.nodeId
const module = getStoreModule(store._modules, modulePath)
if (!module) {
return
}
// Access the getters prop to init getters cache (which is lazy)
// eslint-disable-next-line no-unused-expressions
module.context.getters
Expand Down Expand Up @@ -496,10 +499,8 @@ function getStoreModule (moduleMap, path) {
const names = path.split(VUEX_MODULE_PATH_SEPARATOR).filter((n) => n)
return names.reduce(
(module, moduleName, i) => {
const child = module[moduleName === VUEX_ROOT_PATH ? 'root' : moduleName]
if (!child) {
throw new Error(`Missing module "${moduleName}" for path "${path}".`)
}
const child = module ? module[moduleName === VUEX_ROOT_PATH ? 'root' : moduleName] : null
if (!child) return null
return i === names.length - 1 ? child : child._children
},
path === VUEX_ROOT_PATH ? moduleMap : moduleMap.root._children,
Expand Down