Heat 2 tbsp of the oil in a large non-stick frying pan. Add the aubergine and cook on a high heat in batches until golden. Remove and drain on kitchen paper.
Wipe the pan. Add the remaining 1 tbsp olive oil and cook the onion and garlic for 10 minutes until golden over a medium heat. Add the tomatoes, pesto, aubergine and chilli flakes. Bring to the boil and simmer for 15 minutes.
Meanwhile, cook the pasta in a large pan of salted water for 8-10 minutes or according to packet instructions. Drain the pasta and reserve a little of the pasta water.