To roast the tomatoes, preheat the oven to 350 degrees F (180 C). On a rimmed baking sheet, combine the tomatoes, 2 tbsp. olive oil, and a pinch each of kosher salt, black pepper, and sugar. Stir to coat tomatoes, and bake for about 30 minutes, stirring once or twice while cooking. Remove from the oven and set aside.*
While tomatoes are roasting, combine butter and remaining 2 tbsp. olive oil in a large skillet over medium-high heat. When butter is melted and the skillet is hot, add the onion and cook until softened, 3-4 minutes. Add garlic and red pepper flakes and cook until fragrant, about 1 minute.
Add gnocchi to the pan and stir to coat. Season to taste with additional salt and pepper. Spread gnocchi across the skillet in an even layer, then cook over medium-high heat for 5-7 minutes without stirring, until they begin to brown. At that point, turn over the gnocchi and cook for another 3-5 minutes to lightly brown the other side. Remove from heat.
Stir roasted tomatoes, pine nuts, and basil into the skillet. Top with mozzarella balls, and serve warm. (If you prefer the cheese to melt throughout the dish, either combine the mozzarella balls with the tomatoes right after they come out of the oven, or stir them into the skillet with the tomatoes, pine nuts, and basil. You really can’t go wrong!)
*The tomatoes can be roasted a day or two in advance, if you like. Store the cooled tomatoes in the fridge in an airtight container, and warm briefly in the microwave before proceeding with the rest of the recipe.