Reaction-induced phase separation in modified thermosetting polymers