Direct observation of how the heavy-fermion state develops in CeCoIn5