Using history expansion with ! will do this without an alias or function:
$ grunt compileModule:[something]
$ # other things
$ !grunt
The last !grunt will cause the shell to look up the last command in the command line history that starts with the string grunt and run that.
In bash:
!string
Refer to the most recent command preceding the current position in the history list starting with
string.
If the shell has persistent history (usually enabled by setting HISTFILE), then this will also work across consecutive shell sessions, and depending on the shell, it may even work in concurrent sessions.