Spreading a bailout across all industries affected by the ongoing trade war would cost taxpayers $39 billion, according to a U.S. Chamber of Commerce analysis.

The Chamber opposes the billions in tariffs that President Donald Trump has slapped on a host of goods from China as well as steel and aluminum imports.

To compensate for the economic damage, Trump recently approved $12 billion in emergency aid for farmers who produce certain goods, particularly soybeans. The package was touted as a temporary solution while negotiations continue, but the president has taken seething criticism including from his own party and some farmers themselves.

In its study of what would happen should the aid program spread, the Chamber said the effects would be substantial.

"The best way to protect American industries from the damaging consequences of a trade war is to avoid entering into a trade war in the first place," Neil Bradley, the organization's executive vice president and chief policy officer, said in a statement. "The administration's focus should be expanding free trade and removing these harmful tariffs, not allocating taxpayer's money to only marginally ease the suffering for some of the industries feeling the pain of the trade war."

The aid package, Bradley said, is "a slippery — and costly — slope."

The Chamber compared the total amount of the farmers' aid to the amount of exports affected by the tariffs, then applied the same ratio across other impacted industries, to come up with the bailout requirement if it was applied across the board.

Doing so produced the $39 billion total — $12 billion to the farmers, plus another $27 billion to other industries. The impact ranged from $43 million for starch and glue producers up to $7.6 billion for auto, motorcycle and parts manufacturers.

There have been no indications from the White House that it is considering extending the aid package to other industries.

As a matter of proportion, if the administration did decide to compensate all industries and the Chamber's figures are accurate, the total would amount to about 0.2 percent of GDP and just shy of 1 percent of the fiscal 2018 budget total.

CNBC has reached out to the White House for comment.