I think “tree-shaking” makes sense, because you ARE actually “starting with all of the code” (based on the fact that it’s all there / referenced / available) and then “shaking” out parts of it so that you end up with just what you need.
However, your cake making analogy doesn’t seem to be similar to tree shaking, so it seemed confusing. Although, I understood your point.
Maybe it’s more like putting all of the cake ingredients into a bag (but still in their packaging, so they don’t mix), and then shaking it to cause the unneeded ingredients to “float to the top,” then pouring those out so you’re left with just the needed ingredients in the bag. Now you can give that bag to anyone who wants to eat a cake.
ha ha, just kidding. But I do think “tree-shaking” makes sense.