moleculer
moleculer copied to clipboard
[lodash] Remove usage of _.defaultsDeep
See #433 for context.
Describe the solution you'd like
Remove usage of _.defaultsDeep
throughout Moleculer, or import the dependency directly without bundling the whole lodash lib.
Describe alternatives you've considered
None so far. I have tested using Object.assign
a couple of places where configurations get merged with tests still passing, so that could be feasible.
Additional context https://github.com/moleculerjs/moleculer/search?q=.defaultsDeep&unscoped_q=.defaultsDeep
The problem with Object.assign
is that it doesn't copy the object deeply, only the first level. And there are other differences in the logic how they handle arrays, null
, undefined
.
I would imagine that would cause some issues. We might need to find a standalon solution to this if we do not conclude with that it is sufficient to include the dependency directly from lodash.
I will write a unit test with _.defaultsDeep with moleculer use-cases, and after that, we will able to create a custom implementation.
If want to look this is what i use on my code for merge:
https://gist.github.com/Wallacy/adf546f4de34848e8355d6a511d89647
Should be more simple on pure js; The hard part was be a code with good performance xD;