-
Notifications
You must be signed in to change notification settings - Fork 120
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
Try replacing lodash with deepmerge #126
Conversation
This seems like a fair option to me. If others agree, I would be ok with cutting a beta release to test it out. 👍 |
@btroncone We'll help out testing it whenever you're ready. |
@bufke Is this ready for beta? |
Yes ready for beta. Hopefully we can get more feedback before releasing as stable. |
@btroncone we have 3 👍 and no comments about any issues. Are we as ready as we'll ever be? This DEF merits a major version bump as the chance for very subtle differences is high. I may look into the Angular Universal pull request today too if we do a release any time soon. |
Cool, I’ll merge this in tonight and bump to v8.0. Thanks! 👍 |
Merging 👍 |
The change to deepmerge means that objects in the state tree loose their function definitions. I have confirmed this behavior difference here .
Lodash Merge
Deepmerge
This breaks our code as an object in the initial state tree no longer has its methods after a re-hydration of a different property. I can work around it by re-creating the objects myself on the @ngrx/store/update-reducers action within my own reducer.
I may also look at using a selector that creates the object and then just store a plain old javascript object in the store which would avoid this issue with deepmerge.
Edit:
I will be updating our code to follow this advice and so deepmerge behavior is acceptable. :) |
This might be worth documenting. We could retroactively update the changlog about a known breaking change. @StephenCooper feel free to open a Pull Request clarifying the behavior if you have time. |
Added findings to changelog |
…lstorage * 'master' of https://github.com/btroncone/ngrx-store-localstorage: Update CHANGELOG.md Update CHANGELOG.md chore(release): release version 8.0.0 Try replacing lodash with deepmerge (btroncone#126) Update CHANGELOG.md chore(release): 7.0.1 btroncone#129 updating peer dependencies Add Angular Universal support by checking if browserSide fix btroncone#73
Alternative fix for #123
This change gets the project on a better maintained package. lodash.merge is no longer maintained and suffers from a potential security vulnerability. lodash itself would increase the bundle size to an unacceptable level. Switching to deepmerge actually reduces the webpack bundle size by about 10k compared to lodash.merge.
Previously it was decided to avoid deepmerge due to observed issues when used with the project vuex-persist. This seems only to be unwanted array concatenation instead of replacement. It's easy to avoid this using options set to deepmerge, which this PR demonstrates.
Still this is a significant change and we cannot guarantee the behaviour will exactly match lodash.merge. If we decide to go with deepmerge, I recommend releasing a beta release and asking users to try this out before declaring it stable.