There are many circumstances in which a passport’s life might extend that of a visa.
China recently extended its visa validity period so that tourists can now exit and re-enter the country for ten years before applying for a new visa. Because passports also have a lifetime of ten years, it’s probably impossible that a Chinese visa would expire first.
Say that’s the case and your passport dries up before your visa. As long as the passport the visa is registered to is not lost or stolen, U.S. Customs and Border Protection reports that the visa is still valid and there is no need to reapply for that travel document. Just be sure to carry the new and the old passport when traveling. (We use the example of U.S. visas as the basis for this advice but the country where you applied for the visa has the actual and final authority, so better run it by them in case you’re rejected at the border!)
To boil things down, if a passport expires before the visa registered with it and the old one is on hand, a new visa is usually isn’t necessary. However, if a passport is gone completely or if the visa itself is lost, there will be no way out of applying for a new visa.
There seems to be some suggestion that in the case that a passport is lost, stolen or gone altogether, you will need to reapply for a completely new visa or, if the embassy permits, transfer the visa to the replacement passport — that’s some embassy bungee-jumping you’ll have to deal with there. Same scenario if the visa is lost or damaged, the U.S. State Department says.
That's when I like to engage in practices I like to call defensive traveling. It's always a good idea to Dropbox a copy of the passport and visa page and carry along a physical backup copy in case things go haywire. Though there's a fat chance customs will let you through with that alone, it might be worth taking to the embassy if you have to reapply for a new one and if you can get them to waive the application costs on a miracle. (Hey, it never hurts to try.)
To play it safe, keep copies of both your passport and visa while traveling, too. That way if something either expires or gets lost, the documentation is ready. The way I see it, spending five minutes to make copies of, well, everything sounds a lot better than spending five days making phone calls and filling out paperwork.