I always would prioritize the frame. 99% of the enjoyment comes from good fit and geometry. All the high end shifting nowadays (mechanical or electronic) are pretty good and none will ruin your ride like a wrong frame can.
A drivetrain can be changed and is a wear item anyway.