{"record":{"id":"81232c78bdba5fc8","repo":"vuejs/vuex","slug":"vuex-trying-to-add-a-new-module-key-on-hot","errorCode":null,"errorMessage":"[vuex] trying to add a new module '${key}' on hot reloading, manual reload is needed","messagePattern":"\\[vuex\\] trying to add a new module '(.+?)' on hot reloading, manual reload is needed","errorType":"console","errorClass":null,"httpStatus":null,"severity":"info","filePath":"src/module/module-collection.js","lineNumber":96,"sourceCode":"\n    return false\n  }\n}\n\nfunction update (path, targetModule, newModule) {\n  if (__DEV__) {\n    assertRawModule(path, newModule)\n  }\n\n  // update target module\n  targetModule.update(newModule)\n\n  // update nested modules\n  if (newModule.modules) {\n    for (const key in newModule.modules) {\n      if (!targetModule.getChild(key)) {\n        if (__DEV__) {\n          console.warn(\n            `[vuex] trying to add a new module '${key}' on hot reloading, ` +\n            'manual reload is needed'\n          )\n        }\n        return\n      }\n      update(\n        path.concat(key),\n        targetModule.getChild(key),\n        newModule.modules[key]\n      )\n    }\n  }\n}\n\nconst functionAssert = {\n  assert: value => typeof value === 'function',\n  expected: 'function'","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/vuejs/vuex/blob/bd907467b8392d6671bb115738285ff7f63d0cf6/src/module/module-collection.js#L78-L114","documentation":"During hot module replacement, ModuleCollection.update reconciles the old module tree with new definitions. If a new module definition introduces a child that did not exist in the running tree, Vuex cannot hot-swap it and warns that a manual reload is needed, skipping the update.","triggerScenarios":"Editing store modules with HMR active and adding a brand-new key under modules (e.g. adding modules: { reports } to a store that previously had no 'reports'); hot reload after code-splitting introduces a new nested module.","commonSituations":"webpack/vite HMR during development of Vuex modules; adding a feature module to an existing namespaced parent; new nested route module added while dev server is running.","solutions":["Perform a full page reload (manual reload) so the store is rebuilt with the new module tree","If the module must appear without reload, call store.registerModule after the hot update instead of relying on HMR","Configure the store HMR handler (module.hot.accept) to recreate or merge modules explicitly","Accept this as expected dev-only behavior; production builds are unaffected"],"exampleFix":"// before\nif (import.meta.hot) { import.meta.hot.accept(() => { store.hotUpdate(newModules) }) } // newModules adds a brand-new key\n// after\nif (import.meta.hot) { import.meta.hot.accept(() => { for (const k in newModules) if (!store.hasModule(k)) store.registerModule(k, newModules[k]); store.hotUpdate(newModules) }) }","handlingStrategy":"fallback","validationCode":"function diffModules(oldDefs, newDefs, path = []) {\n  const added = []\n  for (const k in newDefs.modules || {}) {\n    const has = oldDefs?.modules && k in oldDefs.modules\n    if (!has) added.push([...path, k].join('/'))\n    added.push(...diffModules(oldDefs?.modules?.[k], newDefs.modules[k], [...path, k]))\n  }\n  return added\n}\n// if diffModules(old, new).length, do a full store rebuild instead of hotUpdate","typeGuard":"function canHotUpdate(oldModule, key) {\n  return Boolean(oldModule && oldModule.getChild && oldModule.getChild(key))\n}","tryCatchPattern":"if (import.meta.hot) {\n  import.meta.hot.accept(() => {\n    try { store.hotUpdate(newModules) }\n    catch (e) { console.warn('hot update incomplete, reloading', e); location.reload() }\n  })\n}","preventionTips":["Full-reload after adding brand-new modules; HMR only patches existing ones","Register new modules programmatically (registerModule) inside the HMR accept handler","Keep a store rebuild fallback for structural changes","Treat the warning as dev-only; verify production bundle has no stale module paths"],"tags":["vuex","hmr","hot-reload","module-registration","dev-warning"],"backgroundTag":"hmr-module-added","analyzedSha":"bd907467b8392d6671bb115738285ff7f63d0cf6","analyzedAt":"2026-08-28T21:38:57.320Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}