As the U.S. and China hammer out an elusive trade deal, Vietnam is attracting record amounts of foreign direct investments.

In the first 11 months of 2019, the Southeast Asian nation received $31.8 billion in foreign direct investment commitments, a 3% increase year-on-year, said the country’s Foreign Investment Agency, which operates under the Ministry of Planning and Investment.

Processing and manufacturing industries received the largest chunk of foreign direct investment pledgesduring the period – attracting $21.56 billion, or 67.8% of total foreign direct investment commitments.

The biggest slices of foreign direct investment commitments came from Hong Kong ($6.69 billion), followed by South Korea ($5.73 billion), Singapore ($4.47 billion), mainland China ($3.56 billion) and Japan ($3.33 billion).

In terms of actual foreign direct investment disbursements, Vietnam attracted $17.69 billion over the January-November period, a 7.2% jump from the same period of 2018.

During that same period, foreign companies invested $11.24 billion in Vietnam through capital contributions and share purchases, a 47.1% surge from the year-ago period.

Truong Trong Nghia, a partner at law firm YKVN in Ho Chi Minh City, noted Vietnam has attracted some $300 billion in foreign direct investment over the past 20 years.

“The industrial zones, especially the high-tech parks, have already seen investments from companies such as Intel (INTC) and Japan’s Nidsoec Corp., making them an attractive investment destination for foreign investors,” he said.

However, some foreign investors want Vietnam to upgrade the quality of its workforce ito keep attracting foreign funds.

Marko Walde, chief representative of the Delegate of German Industry and Commerce in Vietnam, said German companies and European investors “need people with proper vocational training” in mechanics, electronics and other industrial fields. Walde also cited other drawbacks in Vietnam, including a lack of skilled workers, poor infrastructure, a weak judicial system and an unreliable power supply.

Virginia Foote, vice chairwoman of the American Chamber of Commerce in Vietnam, concurred the country must develop a strong and skilled workforce “to attract investment in engineering, science and technology.”

Moreover, Vietnam is still not an easy place for foreign companies to operate. The World Bank recently ranked Vietnam 70th among 190 economies in terms of the ease of doing business there, citing that it needs to improve the area of insolvency resolution, among others. But the report noted Vietnam has vastly improved such facets as allowing businesses to access finance, paying taxes online and running day-to-day operations.

There is also some evidence that Vietnam is profiting from the trade deal stalemate between the U.S. and China.

During the first nine months of 2019, imports from Vietnam to the U.S. surged by 34.8%, versus a 5.8% gain for all of 2018, said the consultancy IHS Markit. In contrast, imports from mainland China to the U.S. dropped by 13.4% for that period.

Michael Ryan, IHS Markit’s associate director of comparative industry service, wrote that Vietnam’s most rapidly growing export products to the U.S. were computers, telephone equipment and other machinery.

Still, the U.S. is not one of the major investors in Vietnam – only about 2.7% of the total foreign direct investment it has received came from Americans this year.

IHS Markit cited Washington’s lack of a free trade agreement with Vietnam and Vietnam’s still subpar infrastructure as among the factors for the U.S.’ lack of enthusiasm for investing there.

In June of this year, Vietnam signed the European Union-Vietnam Free Trade Agreement, which is expected to increase its trade with Europe significantly.

However. U.S. president Donald Trump pulled out of the Trans-Pacific Partnership – which would have included Vietnam -- in early 2017, fulfilling a campaign promise.

Still, some analysts expect Vietnam to become a major manufacturing hub in the region.

“Given that Vietnam has political and economic stability, an economy that is growing consistently at 5% to 6% per year and a large population, it is a good alternative manufacturing destination,” said Dang Duong Anh, managing partner at the Vietnam International Law Firm in Hanoi. “Some of the manufacturing from China will move to Vietnam, and there has been a small increase in interest in the first eight months of the year.”

Tony Foster, managing partner for Freshfields Bruckhaus Deringer’s Vietnam offices said the trade war between the U.S. and China is now “good for Vietnam in the short term, but can be bad in the long term.”

The European Union-Vietnam Free Trade Agreement, he added, “will be good for the country in the short term and long term.”

For the U.S., Vietnam’s huge trade surplus – running $30 billion to $40 billion annually – presents a problem.

Sesto E. Vecchi, the managing partner of Russin & Vecchi Law Offices in Ho Chi Minh City, cautioned the trade surplus raises risks of the imposition of high tariffs from Washington. “Vietnam should consider taking measures to offset the trade imbalance,” he suggested.

Rajiv Biswas, Asia-Pacific chief economist at IHS Markit, suggested Vietnam could avoid U.S wrath over the trade surplus by “undertaking some substantial purchases of big-ticket capital goods from the U.S.”

Both President Trump and U.S. Trade Representative Robert Lighthizer have criticized Vietnam for maintaining conditions conducive to the trade surplus.

Indeed, Trump has threatened to slap new tariffs on Vietnamese imports.

This past summer, Trump described Vietnam as “the single worst abuser of everybody” and pointed out that some manufacturers from China, South Korea and elsewhere were relocating to Vietnam due to lower labor costs and the ability to reroute their exports to avoid U.S. tariffs.

“A lot of companies are moving to Vietnam, but Vietnam takes advantage of us even worse than China. So there’s a very interesting situation going on there,” Trump said.

Trump added that he was “in discussions with Vietnam” over trade matters.