Peel, core and dice the apples into small pieces, about 1/4 inch each.
Melt the butter in a medium saucepan over medium heat.
Add the diced apples, brown sugar, cinnamon, nutmeg, salt and lemon juice. Stir until everything is evenly combined.
Cook for about 5–7 minutes, stirring occasionally, until the apples begin to soften but still hold their shape.
In a small bowl, stir together the cornstarch and water until smooth.
Pour the cornstarch mixture into the apples and stir well.
Continue cooking for another 1–2 minutes, until the sauce thickens and coats the apples.
Remove from the heat and stir in the vanilla.
Transfer the filling to a bowl and allow it to cool completely before filling the cupcakes.