The answer is to spread out all forms of production globally, so nations don’t lose their smaller local industries that may be less efficient than foreign alternatives. Foreign trade should fill gaps in local production, not kill local industry.
The mechanisms by which this can be accomplished are antitrust and careful application of trade barriers. The obsession with “free trade” has done damage to countries all across the world in order to benefit a small class connected to multinational industry. The short lived benefits came at a huge cost and countries are only just now seeing this.
Free trade/open borders libertarians have lost influence to nationalists because the former position is antithetical to maintaining a functional society. It’s possible to build “libertarianism in one country,” and the sooner that people wake up to that, the better. The alternative is some form of left or right despotism.