Heat the olive oil in a wide skillet over medium low heat and cook the onions for 25 to 30 minutes, stirring every few minutes, until they turn deep amber and smell sweet rather than sharp.
Stir in the sugar and balsamic vinegar for the last 2 minutes of cooking, then season with salt and pepper and let the onions cool for 15 minutes.
Thaw the puff pastry sheet for 40 minutes if it has not already softened.
Preheat the oven to 400F and line a baking sheet with parchment.
Cut the pastry into 16 squares.
Place a tablespoon of cooled onions and a pinch of cheese on one half of each square, leaving a border bare.
Fold the pastry over into a triangle or rectangle, pressing the edges with a fork to seal tightly, since a loose seam lets the filling leak.
Arrange the pastries on the sheet, brush with egg wash, and cut a small slit in the top of each.
Bake for 16 to 18 minutes, until the pastries are golden brown and firm to the touch, then cool for 5 minutes before serving warm.
Good to Know
Caramelize a double batch of onions and freeze half in a flat bag; next time the filling is ready before the pastry even finishes thawing.