moleculer icon indicating copy to clipboard operation
moleculer copied to clipboard

[lodash] Remove usage of _.defaultsDeep

Open abdavid opened this issue 4 years ago • 4 comments

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

abdavid avatar May 22 '20 18:05 abdavid

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.

icebob avatar May 22 '20 19:05 icebob

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.

abdavid avatar May 22 '20 19:05 abdavid

I will write a unit test with _.defaultsDeep with moleculer use-cases, and after that, we will able to create a custom implementation.

icebob avatar May 22 '20 19:05 icebob

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;

Wallacy avatar May 23 '20 21:05 Wallacy