To purposely murder the child is immoral. To do a life-saving procedure on the mother that results in the child dying - but killing the child is not the goal - is morally acceptable.
Ectopic pregnancies and some other emergencies during pregnancy fall under the morally acceptable category.