An eSIM will prevent a physical swap. However, an eSIM will not prevent a port-out of your phone number.
To defend against port-out you should enable port protection. The name of such a feature varies by carrier, and T-Mobile seems to refer to it as "Takeover Protection."