In reaction 1 of Preparation A, the 4-chloropyrrolo[2,3-d]pyrimidine compound of formula XXI, wherein R is hydrogen or a protecting group such as benzenesulfonyl or benzyl, is converted to the 4-chloro-5-halopyrrolo[2,3-d]pyrimidine compound of formula XX, wherein Y is chloro, bromo or iodo, by reacting XXI with N-chlorosuccinimide, N-bromosuccinimide or N-iodosuccinimide.