Deepmerge breaks modules not related to persist
See original GitHub issueAfter updating to vuex-persist 3.1.3 modules that are not related in any way to vuex-persist plugin are broken when they’re using classes as a part of state. Also i’m using vuex-module-decorators.
For example:
class Foo {
a = 5;
bar () {
this.a = 6;
}
}
@Module({ namespaced: true, name: 'foo' })
class FooModule extends VuexModule {
foo = new Foo();
@Mutation
baz () {
this.foo.bar();
}
}
const persist = new VuexPersist({
modules: ['other', 'some-other-module-2']
})
On the application start it throw an error that foo.bar()
is not a function. It would make sense when the module would be loaded by vuex-persist
but it it not so it should be not touched.
Everything worked fine when the backend besides merging was handled by lodash. Everything broke after moving to deepmerge.
What it the solution to this? Temporarily we’re using older version but that’s not a good option for a long time.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Developers - Deepmerge breaks modules not related to persist -
After updating to vuex-persist 3.1.3 modules that are not related in any way to vuex-persist plugin are broken when they're using classes as...
Read more >Javascript deepmerge breaks objectid - node.js - Stack Overflow
I answered my own question, but I'm not sure it's the right answer. query = deepmerge(engageQuery, query, {clone: false});.
Read more >Even more DRY and maintainable code with Terragrunt
Suppose you have a generic VPC module, and you want to always configure VPC flow logs. ... Using deep merge to DRY nested...
Read more >deepmerge - npm
A library for deep (recursive) merging of Javascript objects. Latest version: 4.2.2, last published: 3 years ago. Start using deepmerge in ...
Read more >vuex-persist | Yarn - Package Manager
A Typescript-ready Vuex plugin that enables you to save the state of your app ... BREAKING: replaced lodash.merge with deepmerge (this can cause...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I have ended up writing this functionality on my own in the projects I’m using it with, caues it looks that library is somehow abandoned.
I also couldn’t find any reason besides #64 why lodash was replaced when it was working perfectly fine.
I have a similar issue. I created store including
Map
andSet
value in state, but both are converted to empty objects.This is caused by the behavior of merging object by deepmerge, which replaced lodash.merge from 3.x.
I think another library like just-extend or something should be used. just-extend is a zero-dependency package, so its bundle size is tiny.