I think, if I'm recalling it correctly, that the component that is defining it in the docs can be either client or server and by marking the functiom as server only, Next knows to do magic.
This kind of noodley bundling opt-out is also extremely dangerous from a security perspective. I expect there are a lot of Next.js apps leaking code and possibly secrets that should only be available on the server.