Clean and update build output more intelligently

Fixes #183.
Should I leave this here to be consistent with the TypeScript compiler, or do we want to deal with this in the separate PR too?