Add the oil to a medium pot (there should be at least 2 in/5 cm of clearance between the oil and the rim of the pot). Add the star anise, cinnamon stick, bay leaves, Sichuan peppercorns, black cardamom pod (if using), cloves (if using), garlic, and shallot.
Set the pot over medium heat to start, and bring the oil temperature to 225-250° F / 110-120° C. When it comes up to temperature, lower the heat to medium low.
The oil should be causing small bubbles to slowly rise from the aromatics. If you notice the spices sizzling more vigorously than that or turning dark too quickly, reduce the heat to cool it down. If you are not achieving small bubbles, slowly increase the heat. Hovering close to 225° F is the safest way to prevent burning.
Infuse the aromatics this way for 45-60 minutes. About 20 minutes in, or when the garlic and shallots turn a deep golden color, remove them to ensure they do not make the oil bitter.
Remove the oil from the heat and use a fine-meshed strainer to remove all of the solids. You may need to pour the oil into a bowl and then transfer it back into the same pot.
Set the pot over medium heat. With the oil temperature at 235°F, add the black beans and cook for 20 minutes. The goal is to cook off any residual moisture and lightly fry the beans so they are entirely soaked with oil.
While the beans are frying, heat a wok over high heat until smoking to ensure it’s free of moisture. Reduce the heat to medium, and let the wok cool for a few minutes.
Add a small spoonful of chilies to ensure it’s not too hot and the chilies won’t burn before adding the rest. Roast all the chili flakes for about 10-15 minutes, stirring constantly with a wok spatula, or until they take on a dark red color (about 2-3 shades darker than you started with). There should be no burnt smell, only a robust, spicy aroma.
Add the sugar to the black beans and oil, and stir for about 1 minute to dissolve. Turn off the heat, ensuring the oil is still at a temperature of 235°F when you do. Add the chilies to the pot, and stir to combine. Stir in the dark soy sauce.
Allow the oil to cool. Store in airtight containers in the refrigerator. Always use a clean utensil when handling to prevent spoilage. It can last for up to 6 months if handled in this way.
Nutrition information is per serving. 1 serving = about 1 tablespoon