Economists would argue the jobs go to where they are more efficiently done. The trouble is, "efficient" means pushing negative externalities onto someone else e.g. pollution, lax labor laws, forced labor. All of them condoned and sometimes actively encourage by the ruling regime. Then again, being forced to work in a sweatshop and having a minimum amount of food is better than not working and starving.
Is to not let millions of job leave the country in the first place. And preferably not to countries that abuses human rights.