- Factories like that would be unlikely to survive an invasion in any case.
- China has domestic chip manufacturers that would end up being a lot more dominant. I'm sure their long term strategy is to not be dependent on Taiwanese imports. I'd be surprised if they have not been implementing that strategy for many years. A threat like this would only accelerate this.
- Threatening with economic suicide is not a great defensive strategy. Somebody might call your bluff.
Of course what the Ukrainian situation has made very clear is that you can invade a country and behave like animals without triggering offensive actions against you from other countries. That's a line NATO just won't cross. Taiwan is not a country many countries even actually acknowledge as a country. They are not a NATO member. Clearly, if it comes to an invasion, they have the choice between economic suicide plus destruction and a quick capitulation. The Russians are doing a great job of show casing what it looks like when you choose to fight.
Countries are happy to supply weapons to Taiwan and the Ukraine. However, the world is much more dependent on the Chinese economically than it ever was on Russia. Russia is a tiny market to export to and it does not export that much else besides oil and gas. China on the other hands exports a lot of stuff that is integral to supply chains around the world. And it's a huge market. And it's going to be the largest economy in the world pretty soon.
The deterrent against a Chinese escalation in Taiwan would have to be economical. But economical sanctions at the scale Russia is currently is experiencing would be a form of mutually assured economic self destruction that is simply unthinkable. It's basically the nuclear option and about as desirable for any side. Even the mere threat of that would cause economic unrest world wide.