1. Lay eggplant on paper towels and season with salt. Let stand 15 minutes. Bring a large pot of salted water to a boil. Preheat gas grill or broiler to high.
2. Blot eggplant dry with a paper towel. Brush on both sides with 3 Tbsp. oil. Grill or broil, turning once, until browned and softened, 6 to 8 minutes total. Set aside to cool slightly, then coarsely chop.
3. Cook spaghetti as package label directs until al dente, about 8 minutes. Drain pasta, reserving 1/4 cup cooking liquid. Toss spaghetti with eggplant, tomatoes, basil, garlic, Parmesan, remaining 2 Tbsp. oil and 1/2 tsp. each salt and pepper, adding cooking water as necessary to moisten. Toss with ricotta and serve immediately.