To make the custard, whisk egg yolks, sugar, and cornstarch in a bowl until pale and thick.
Heat milk in a saucepan until simmering, then slowly whisk it into the egg mixture to temper.
Return the mixture to the saucepan and cook over medium heat, whisking constantly until thick and bubbling.
Remove from heat, stir in vanilla and 2 tablespoons of butter, then chill in the refrigerator with plastic wrap touching the surface.
Preheat oven to 400°F (200°C) and line a baking sheet with parchment paper.
In a clean saucepan, boil 1/2 cup butter, water, and salt; remove from heat and stir in flour until a dough ball forms.
Return to low heat and stir for 2 minutes to cook out moisture until a thin film forms on the pan.
Transfer dough to a mixer; beat in eggs one at a time, ensuring each is fully incorporated before adding the next.
Pipe 2-inch mounds onto the baking sheet and bake for 25 minutes until golden brown and firm.
Pierce each shell with a toothpick to let steam escape, cool completely, then pipe the chilled custard into the centers.