Making the filling:
Heat a frying pan over a medium heat.
Add the olive oil and chopped shallots. Season with salt and cook the shallots with occasional stirring until they've softened and caramelised. This should take about 5-10 minutes. Adjust the heat as necessary.
Once the shallots have caramelised, add the Swiss chard (or spinach) and cover the pan with a lid. Cook over medium heat with occasional stirring until the chard has fully wilted. Uncover the pan and cook for a further 1-2 minutes until most of the moisture released by the chard has evaporated.
Transfer to a large bowl and allow to cool completely to room temperature.
Once cooled, add the cream cheese, coarsely grated cheddar, salt and pepper, and mix well until evenly combined. Make sure to taste the filling and adjust the seasoning. Set aside until needed.