In a medium saucepan, combine the milk and chocolate (chop the chocolate into pieces if using a bar chocolate). Heat over medium-low until the chocolate is melted and the mixture is warm.
In a medium bowl, whisk together the egg yolks, sugar, cornstarch, and salt until smooth. While whisking constantly, ladle in 1/2 cup or so of the warm milk mixture into the bowl, whisking vigorously (this is tempering the eggs so they don’t curdle when cooked on the stovetop). Continue ladling in another one or two scoops of the milk mixture and whisk until the egg mixture is smooth.
Pour the tempered egg mixture into the saucepan with the remaining chocolate milk mixture, whisking constantly. Cook over medium heat, continuing to whisk the entire time, until the mixture is bubbling and thick, 4-5 minutes.
Remove from the heat and stir in the butter and vanilla. Transfer the pudding to a bowl and cover with plastic wrap. Let the pudding come to room temperature, about 45 minutes to an hour.
When both the crust and pudding are cool, spread the pudding evenly in the pie crust. Cover and refrigerate for 2-3 hours, until the pudding is set.