“The Chinese Exclusion Act,” appearing Tuesday as part of PBS’s “American Experience,” was in the works well before the election of Donald Trump. But it feels as if it were made for a moment when border walls and immigration controls are topics of daily conversation.

Directed by the PBS stalwart Ric Burns and his longtime collaborator Li-Shin Yu (who was an editor on the 2003 PBS series “Becoming American: The Chinese Experience,” which covered some of the same ground), the documentary is centered on the 1882 act of the title, the first American law to restrict the immigration of a particular ethnic group and ban its members from citizenship.

But the film’s scope is far larger. Tracing the story of Chinese immigration from 1840 (when the United States census showed a total of four Chinese among a population of 17 million) to the present, it provides a well-documented but not well-known alternate history — a corrective to the national myth of the melting pot.

The filmmakers and their cast of mostly Asian-American historians frame the Exclusion Act as part of a long national narrative of racism, xenophobia, predatory capitalism and political calculation. The China trade and the Opium Wars, the Civil War and the collapse of Reconstruction, and cycles of economic depression and labor unrest all figure into a story that doesn’t begin to turn until well after World War II. It’s also a cautionary tale, reminding us that open ideas about immigration and citizenship that are now under attack have only had currency since the 1960s.