| Let’s start with something simple, like difference(). 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.