BEIJING — Whatever deal Washington and Beijing reach over the trade war, President Trump has already scored a big victory: Companies are rethinking their reliance on China .

The two sides are nearing an agreement, with Mr. Trump saying on Thursday that an “epic” trade pact could be weeks away and that he may soon meet with President Xi Jinping, China’s top leader. But already, spurred by tariffs and trade tensions, global companies are beginning to shift their supply chains away from China, just as some Trump administration officials had wanted.

The move, known as decoupling, is a major goal of those who believe the world has grown far too dependent on China as a manufacturing giant. As Beijing builds up its military and extends its geopolitical influence, some officials fear that America’s dependence on Chinese factories makes it strategically vulnerable.

Now companies in a number of industries are reducing their exposure to China. GoPro, the mobile camera maker , and Universal Electronics, which makes sensors and remote controls, are shifting some work to Mexico. Hasbro is moving its toy making to the United States, Mexico, Vietnam and India. Aten International, a Taiwanese computer equipment company, brought work back to Taiwan. Danfoss, a Danish conglomerate, is changing the production of heating and hydraulic equipment to the United States.