How to create dynamic template to compile dynamic component?

I would strongly suggest doing pretty much anything possible to avoid this. Production mode is going to cause you nightmares. I have yet to see a situation where this can’t be faked using a (potentially heterogeneous) array, a loop and switch. See this for an example.