The US trade deficit has narrowed to its lowest level in more than two years, driven by record exports boosted by the weaker dollar.