-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
add warnings when the different namespaced modules has the same names… #1554
Conversation
src/store.js
Outdated
if (process.env.NODE_ENV !== 'production') { | ||
console.error(`[vuex] duplicate namespace ${namespace} for the namespaced module ${path.join('/')}`) | ||
} | ||
return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't return here please. It will change the current behavior which need major version bump.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes,I see.
I have removed the return.Thanks.
src/store.js
Outdated
@@ -301,6 +301,12 @@ function installModule (store, rootState, path, module, hot) { | |||
|
|||
// register in namespace map | |||
if (module.namespaced) { | |||
const existedModule = store._modulesNamespaceMap[namespace] | |||
if (existedModule) { | |||
if (process.env.NODE_ENV !== 'production') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we merge both if
statement into one so that uglify will remove entire statement on production build?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, thanks.
I have changed that.
Thank you! |
Thanks again! 💚 |
…names… (vuejs#1554) * add warnings when the different namespaced modules has the same namespace * Add warnings when duplicate namespace for different namespaced modules * Add warnings when duplicate namespace, merge if
Add warnings when the different namespaced modules has the same namespace.
There is a situation that different namespaced modules could have the same namespace, so when in the method of installModule, generate store._modulesNamespaceMap, the follow module will override the before module.
For example:
the module m1 has the namespace 'm1',
the module m2/m1 has the same namespace 'm1'
so in the store._modulesNamespaceMap the module m2/m1 will override the module m1