The tech sector has benefitted from globalism, but only because it's taken a while for other countries to catch up and develop their own industries.
China allows us to sell cars in China, but only if we build them there. They don't allow their citizens to invest in our stock market, but happily allow us to invest in theirs. The free trade is completely one sided
But thats how it works...
And how it worked all throughout history...
You have to have the technological edge to survive as a dominant economic power house, and provide prosperity to your people as a result, like US did for the last 100 years before it was not sustainable anymore.
As you said, the main problem is that the technology gap between US and other countries closing.
So what to do in this case?
You either go to the direction of protectionism...
Or you step the gas pedal and try your best to advance your tech even further...