Combine pineapple, jalapeños, red onion, ginger, brown sugar, vinegar, cumin, salt, pepper, and optional chili flakes in a saucepan over medium heat.
Bring to a gentle boil, then reduce heat and simmer uncovered 20–30 minutes, stirring occasionally, until thickened.
Stir in lime juice and cilantro. Cool to room temperature before storing in the refrigerator for up to 2 weeks.
