This dish takes some patience, since you need to brown the tofu first, but the time is well worth it: The tofu develops a nice brown crust around its silky interior.
Whisk together the ginger, soy sauce, chiles, turmeric, sugar, and salt in a shallow dish until well combined. Add the tofu pieces, turning to coat. Cover and refrigerate for at least 1 hour and up to 24 hours.
Heat half the oil in a nonstick skillet over medium heat and add the onion, shallots, and garlic. Sauté, stirring occasionally, until fragrant and softe