Currently, the bulk of US R&D will be done by Chinese and Indian grad students in US universities -- who will return with those skills to their native countries
The most valuable intellectual wealth of a country is not in its patent files or published scientific papers -- it is in the skulls of the people who are doing the work. It's hard to transfer skill purely by books and papers -- sometimes you need to work alongside people who know what their doing and absorb it by osmosis.
The way the US lost its immense tech lead was by letting in so many foreign tech students, who then returned to their home countries with knowledge that US companies had spent large fortunes to figure out.