(Bloomberg Opinion) -- Nationalism has been a feature of political discourse in Indonesia since the republic's inception after World War II. It's taken on more of an edge since the Asian Financial Crisis and return to democracy. Now, in every election, candidates compete to trumpet their economic patriotism. In the current campaign, which culminates in Wednesday’s vote, challenger Prabowo Subianto has gone further and accused elites of selling out the country.

Chinese projects will get some new scrutiny, his campaign says. The impulse is understandable: A similar strategy worked for candidates in countries from Malaysia and Sri Lanka to the Maldives, where incumbents were charged with signing opaque and unbalanced deals for Chinese infrastructure investment. Whatever government emerges after the vote, however, will need to be pragmatic in how it handles relations with Beijing.

Indonesia’s nationalist sentiment goes well beyond China. Even American companies have been sporadic targets under President Joko “Jokowi” Widodo. The finance ministry sanctioned JPMorgan Chase & Co. after a sell recommendation on Indonesian stocks and the government last year took a majority stake in Freeport-McMoRan Inc.'s Grasburg mine in the eastern province of Papua.

This kind of behavior is great for headlines and appealing to voters. There's also little sign nationalism has hurt Indonesia's economic performance in a pronounced way. Growth has fallen short of Jokowi's target of 7 percent; the expansion has chugged along at around 5 percent. But Indonesia is hardly unique in missing forecasts. The Federal Reserve, for example, has similarly been too optimistic.

At the same time, despite its rhetorical appeal, unvarnished economic nationalism is rarely a long-term winner. Indonesia could certainly use the faster growth that foreign investment can bring, not to mention the infrastructure that China’s offering to build.

Countries across Southeast Asia, even Malaysia, are realizing that such big-ticket projects are unlikely to be financed domestically and it makes little sense to completely tick off a patron as powerful as China. National leaders can haggle for, and sometimes get, better terms. That's better than simply spurning what's on offer.

On the campaign trail, for instance, Malaysia’s nonagenarian Prime Minister Mahathir Mohamad railed that his predecessor had saddled the country with too much debt from giant projects, many involving China, and pledged to scrutinize them. Soon after his return to power, Mahathir even shelved an expensive cross-country rail line temporarily.

A complete end to the project was never really on the cards, though, for multiple reasons: Work had begun; Mahathir loved huge public works during his previous stint in office; and China had an interest in appearing sensitive to domestic constraints. During a visit to New York last year, Mahathir described his concerns about China-backed projects mostly in terms of debt and cost. He didn't chastise Beijing so much as the previous Malaysian government.

Mahathir’s deal last week with China that will allow the controversial rail line to proceed is a model of realism. The project will get built, but the track will be shorter and cost about a third less.

It’s fine to be a China skeptic on the campaign trail. Once in office, though, leaders have to manage relations with Beijing if they want to address their undeniably pressing needs. Indonesia is a far bigger economy than Malaysia and, with its population and role in the Islamic world, a much bigger strategic play for China. That will give its next government leverage.

There are examples of how to use it close at hand. Jakarta's long-awaited subway was opened this year, with the help of a $1 billion loan -- not from China, but from Japan. Tapping money from countries and international institutions that are worried about the spread of China’s Belt and Road initiative is one obvious way to lessen dependence on Beijing.

China's receptivity to a new arrangement with borrowers is also telling. It wants the Belt and Road to be a success. That means avoiding public-relations debacles in countries that have megaphones.

For its part, China can help ease fears about its investments by making them more transparent and equitable. That means cutting other Asian nations a few breaks, as they did with Mahathir. If leaders around the region are willing to be pragmatic about Chinese money, their Chinese counterparts should be as well.

To contact the author of this story: Daniel Moss at dmoss@bloomberg.net

To contact the editor responsible for this story: Nisid Hajari at nhajari@bloomberg.net

This column does not necessarily reflect the opinion of the editorial board or Bloomberg LP and its owners.

Daniel Moss is a Bloomberg Opinion columnist covering Asian economies. Previously he was executive editor of Bloomberg News for global economics, and has led teams in Asia, Europe and North America.

©2019 Bloomberg L.P.