I've changed this because the double merge just looks confusing and unnecessary to me.

Objects are merged from left to right and `opts` should have precedence so this approach should make this a bit more obvious.