Fix throw exception on emit file

Fix issue #852
Nit: Can you remove the commas after the words "all" and "file", and change it to "non-external module"?