add --esm
flag and the follow up logic
#58
+74
−13
Merged