I hit a wall this week when I needed to deep merge two JavaScript objects for Cushion’s the onboarding form. I start with an object of default form values, then I merge the user model on top, so any missing values on the user model are filled in by the defaults.

Previously, I would’ve used lodash without giving it a second thought, but JavaScript has actually come a long way since then, and this would mean adding a new dependency for a few utility methods that I could potentially write myself. This reminds me of a friend’s view on restaurants—he only orders dishes that he can’t easily make himself. This got me thinking about writing my own method and knowing exactly how it works, but that feels like a slippery slope. If writing a deep merge method isn’t as straightforward as I think, then I’ve just spun my wheels and used up precious time on something that has little to do with my end goal of onboarding.

However, I also think that using a utility library like lodash is a slippery slope. I might find myself lazily defaulting to lodash methods when vanilla JS would be the same amount of code—the classic jQuery-as-JavaScript approach. In the time since using lodash in the past, I’ve actually learned plenty of native methods that I could use instead of lodash—many of which are listed here. This explains why I’m more confident about not needing a 3rd party utility library, but stepping back, I don’t think it’s the right decision when I’m trying to make progress on Cushion, the business.

At the end of the day, I’m still torn. Early on, I would add dependencies whenever I needed to do anything that already existed in an NPM package. Now that I’ve maintained several apps and been burned by dependencies countless times, however, I’m reluctant to add another one unless I absolutely need to. While I do appreciate the time they buy me, that’s often only short-term. I still regret several dependencies in Cushion that I’ll inevitably need to remove and rewrite, but maybe the more optimistic view is to realize that they served their purpose at that time.

In this case, I’m only looking at long-term. Time is wide-open and I’m not longer sprinting. Maybe I’ll try writing this one method, see how it goes, and if I find myself needing a dozen methods that already exist in lodash, I’ll reconsider.