Whether to take a dependency is a tricky thing that really comes down to engineering judgement- the thing that you (the developer) are paid to make the calls on.
It’s not even a judgement call at this point. It’s more aligned with buckling your seatbelt, pointing your car off the road, closing your eyes, flooring it and hoping for a happy ending.
Or At the time of adding you can add a NOTE or FIXME comment stating where you copied it from. A quick grep for such keyword can give you a nice overview of nice to have stuff. You can also add a ticket with all the details if you're using a project management tool and resuscitate it when that hypothetical moment happens.
But again, if the discussion is going to be that specific, then you would need to provide actual examples, so that we could judge, whether we would implement that ourselves or it would be difficult to do so. Note, that often it is also not required for ones use-case, to have a 100% matching behavior either. The goal is not to duplicate lodash. The purpose of the extracted or reimplemented function would still be ones own project, where the job of that function might be much more limited.
https://github.com/lodash/lodash/blob/main/dist/lodash.js#L7...
So you also need to copy isArrayLikeObject, baseDifference and baseFlatten.
For baseDifference, you also need to copy arrayMap and baseUnary.
For baseFlatten, you also need to copy arrayPush.
For isArrayLikeObject, you also need to copy isArrayLike and isObjectLike.
For isArrayLike, you also need to copy isLength and isFunction.
For isFunction, you also need to copy isObject and baseGetTag.
For baseGetTag, you also need to copy getRawTag and objectToString.
I don’t have time to dig any deeper, just use tree-shaking ffs.
Tree shaking however, will not help you, if you have to first install a library using NPM. It will only help you reduce overhead in the code served to a browser. Malicious code can run much earlier, and would be avoided, if you rewrite or extract relevant code from a library, avoiding to install the library using NPM. Or is there some pre-installation tree shaking, that I am unaware of? That would actually be interesting.