Preheat the oven to 350°F (175°C) and line the muffin pan with paper cupcake liners.
In a medium bowl whisk together the flour, baking powder, and salt.
In a large bowl beat the softened butter and granulated sugar with a mixer until pale and fluffy, about 2–3 minutes.
Add the eggs to the butter mixture one at a time, beating well after each addition.
Beat in the vanilla extract until combined.
Add half of the dry ingredients to the wet mixture and mix on low just until combined.
Pour in the milk and mix on low until mostly incorporated.
Add the remaining dry ingredients and mix just until a smooth batter forms, scraping the bowl as needed.
Gently fold the chopped raspberries into the batter with a spatula.
Divide the batter evenly among the 12 liners, filling each about two-thirds full.
Bake the cupcakes for 16–18 minutes or until a toothpick inserted in the center comes out clean.
Remove the pan from the oven and let the cupcakes cool in the pan for 5 minutes.
Transfer the cupcakes to a wire rack to cool completely, about 25 minutes.
While the cupcakes bake, make the compote by combining raspberries, sugar, and lemon juice in a small saucepan.
Cook the raspberry mixture over medium heat, stirring and gently mashing, until the berries break down and begin to bubble.
In a small bowl stir together the cornstarch and water, then add this slurry to the saucepan.
Simmer the compote for 1–2 minutes until slightly thickened, then remove from heat.
Strain the compote through a fine-mesh strainer if you prefer a seedless puree, then cool completely.
For the buttercream, beat the softened butter in a medium bowl until creamy and smooth.
Gradually add the powdered sugar, mixing on low at first and then increasing to medium speed until thick and fluffy.
Beat in the vanilla extract and salt.
Add 2 tablespoons of cooled raspberry compote or puree and beat until evenly tinted and smooth, adding more to taste if needed.
If the frosting is too thick add milk or cream 1 teaspoon at a time until it reaches a spreadable or pipeable consistency.
Once the cupcakes are completely cool, optionally core a small hole in the center of each cupcake and spoon in a little raspberry compote.
Frost the cupcakes with a spatula or pipe the raspberry buttercream on top as desired.
Garnish with an extra fresh raspberry on each cupcake if you like and serve.