Make the pineapple curd: Whisk the granulated sugar, pineapple juice and salt in a medium saucepan. Whisk in the eggs and egg yolks until combined. Cook over medium heat, whisking constantly and reducing the heat if the mixture starts bubbling too much, until the curd is the consistency of pudding, 7 to 8 minutes (you should have a little over 1 cup).
Remove from the heat and whisk in the butter and rum (if using). Strain the curd through a fine-mesh sieve into a bowl, pressing it through with a rubber spatula. Cover with plastic wrap, pressing it directly on the surface, and refrigerate until completely cooled, about 2 hours.
Meanwhile, make the cupcakes: Preheat the oven to 350˚ F. Line 12 muffin cups with paper or foil liners. Whisk the flour, baking powder and salt in a medium bowl. Combine the butter, granulated sugar and brown sugar in a large bowl and beat with a mixer on medium-high speed until light and fluffy, 3 to 4 minutes. Beat in the eggs, one at a time, then beat in the vanilla. With the mixer on medium speed, beat in half of the flour mixture, then the milk, then the remaining flour mixture until combined.
Divide the batter among the muffin cups, filling them two-thirds of the way. Bake until a toothpick inserted into the centers of the cupcakes comes out clean, 20 to 25 minutes. Transfer to a rack and let cool 10 minutes in the pan, then remove the cupcakes to the rack to cool completely.
Make the frosting: Combine the butter and confectioner's sugar in a large bowl; beat with a mixer on medium-high speed until smooth and fluffy, 2 to 3 minutes. Add the coconut extract and milk; beat until smooth.
Using a paring knife, cut a slit in the top of each cupcake, cutting about three-quarters of the way down. Fill a piping bag with the pineapple curd; pipe the curd into the slit in each cupcake. Fill another piping bag with the frosting and pipe onto the cupcakes (or spread the frosting on the cupcakes). Top with the shredded coconut.