Let's assume memory in laptops out nowadays are in the 4 to 8gb range.
CPU and ideally an SSD.
When you're compiling stuff it will work your cpu and hd over pretty well.
You may try doing what you want on a computer you currently have and see where your bottlenecks are and find a computer that complements your needs.
My 5 year old laptop does fine with 4gb ram. It's a dual core Intel with a 7200rpm hard drive. I know a faster, quad core CPU would help immensely and an SSD would be that much better. I could probably speed up compiles some by having the source code on one physical drive and the output on another physical drive. With an SSD, though, you're taking the spinning hard drive out of the equation.
As with any computer purchase I recommend setting your price and getting as much performance as you can for that price.