Preheat and Prepare Pan: Preheat the oven to 350°F (177°C) and adjust the oven rack to the center position. Line a 9×13-inch baking pan with parchment paper, leaving overhang on the sides. Set aside.
Mix Dry Ingredients: In a large bowl, whisk together the flour, baking soda, ginger, cinnamon, allspice, cloves, nutmeg, black pepper, and salt. Set aside.
Combine Wet Ingredients: In a medium bowl, whisk the melted butter, brown sugar, granulated sugar, and molasses until smooth. Whisk in the egg and vanilla extract.
Combine Wet and Dry Ingredients: Pour the wet mixture into the dry ingredients and mix with a large spoon or spatula until no flour lumps remain. The dough will be thick.
Transfer and Bake: Spread the dough into the prepared pan, pressing it into an even layer (it will be thin). Bake for 23–26 minutes, or until the top is set but soft, and a toothpick inserted in the center comes out with a few moist crumbs. Do not overbake. Cool in the pan for at least 1 hour.
Make Frosting: Using a mixer, beat cream cheese and butter until smooth, about 2 minutes. Add confectioners’ sugar, ginger, cinnamon, allspice, and vanilla. Mix on low for 30 seconds, then beat on high for 2 minutes. Taste and add a pinch of salt if desired.
Frost and Garnish: Spread frosting over the cooled bars. Add sprinkles if desired. Refrigerate for 30 minutes before slicing for cleaner cuts. Use the parchment overhang to lift the bars from the pan and cut into squares.
Store: Cover and store in the refrigerator for up to 5 days. Plain bars (without frosting) can be stored at room temperature for up to 3 days or refrigerated for up to 1 week.