I was wondering what happens to the effects of trade goods to the civ that built them but lost them to an invasion.
You have to take them on a case by case basis. If you lose Harmony Crystals, which has a civ-wide effect, then the effect is lost right away. The Xinathium Hull Plating is handled differently. Think of that one like a component that you can install on a ship. After you have researched and built it, you have a component that is automatically installed on all ships you build, but it doesn't cost anything, and doesn't take up any space. Sweet. It does not, however, magically appear on the ships that you have already built, and it doesn't go 'poof', if you lose the facility.
This brings up an interesting question. If, after I build the X Plating, I upgrade a ship to the same model, will the +15 be applied?
What happens if you trade the trade goods to another civ on diplomacy? Do you lose it and the other civ get it?
Nope. When you do this, you are only selling/trading the 'license' to manufacture and use it. You don't lose anything; you are just selling the other civ the right to use it also; and since you retain the rights to this good, nobody that you sell/trade it to can pass it along to any other civ.