Preheat oven to 400°F (200°C). Cube butternut squash, toss it with 1 tablespoon olive oil, thyme, salt, and pepper. Roast for 20-25 minutes until tender.
Meanwhile, heat remaining olive oil and butter in a skillet. Add onions with a pinch of salt and caramelize for 30-40 minutes until golden brown.
Reduce oven temperature to 375°F (190°C). Roll out puff pastry on a parchment-lined baking sheet. Spread caramelized onions over pastry, add roasted squash, and sprinkle with cheese. Fold edges of pastry inward and brush with beaten egg.
Bake for 25-30 minutes until pastry is puffed and golden brown.
Cool for a few minutes before slicing; drizzle with balsamic glaze or honey if desired.
Notes
For a perfectly flaky crust, ensure your butter is cold and handle the pastry as little as possible.