afaik tree-shaking is an old old term, it might be less obvious in the web context because it's probably inherited from 70s programming languages (lisp, smalltalk or similar, i can't really say).
Yes, in image based languages DCE is used inside functions to eliminate things like branches that can never be executed, but a function that is never called is not dead code since it might get called later. Tree shaking is used to optimize the final deliverable by saying that there will be no more changes or `eval`s, so anything that isn't reachable from the root(s) can be eliminated.
Whether dead-code elimination would remove whole functions depends on some basic assumption of the tool doing it --- usually a compiler. Some languages are considered closed worlds whereas others are usually considered as open worlds, e.g. Smalltalk, Java and Lisp. Under an open world assumption, everything that could be called by some code added later has to be retained. Some tools nevertheless apply a closed-world assumption to an "open world language" and take additionaly arguments what to consider entry points that should be retained. An example for such a tool is Proguard in the Java world.