From 51ba8adf4b53e2a87398d42ab6184d7a0777de77 Mon Sep 17 00:00:00 2001 From: Guillaume Chau Date: Thu, 28 Mar 2019 14:04:41 +0100 Subject: [PATCH] fix(vuex): early unregister module, closes #922 --- src/backend/hook.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/backend/hook.js b/src/backend/hook.js index 65935bee9d..6d216e9946 100644 --- a/src/backend/hook.js +++ b/src/backend/hook.js @@ -110,14 +110,16 @@ export function installHook (target) { if (typeof path === 'string') path = [path] hook.storeModules.push({ path, module, options }) origRegister(path, module, options) + if (process.env.NODE_ENV !== 'production') console.log('early register module', path) } const origUnregister = store.unregisterModule.bind(store) store.unregisterModule = (path) => { if (typeof path === 'string') path = [path] const key = path.join('/') const index = hook.storeModules.findIndex(m => m.path.join('/') === key) - if (index !== -1) hook.storeModules.splice(0, 1) + if (index !== -1) hook.storeModules.splice(index, 1) origUnregister(path) + if (process.env.NODE_ENV !== 'production') console.log('early unregister module', path) } hook.flushStoreModules = () => { store.registerModule = origRegister