Preheat the oven to 400 degrees F.
In a baking tray lined with parchment paper, lay tomatoes in a single layer. Add basil leaves and garlic head. Drizzle with olive oil and season with salt and pepper. Roast for 30 minutes until the tomatoes start to burst and release their juices.
When it’s cool enough to handle, squeeze out the garlic pieces. Reserve a few stems with tomatoes on them for serving. This step is completely optional.
In a separate baking tray lined with parchment paper, spread out the eggplant cubes. Toss with olive oil, sprinkle oregano, and season well with salt. Roast for 30 minutes until the eggplant becomes soft and golden brown.
To make the pasta sauce, heat oil in a large saucepan over medium heat. Add shallots and cook for 5 minutes until fragrant.
Add roasted tomatoes, garlic, eggplant, and their juices. Turn the heat to medium high and cook for 20 minutes until thickened.
Add in the fresh basil leaves and cook for another 5 minutes.
Stir in the sugar until it dissolves. Season with salt and pepper and adjust according to taste. If the sauce is too thick, add in a tablespoon of pasta water at a time to thin it out.
While the sauce is simmering, cook pasta according to the package’s instruction.
Divide the pasta among serving plates. Top with sauce, extra roasted tomatoes, basil, and Parmesan cheese.