Add some checks and comments to pack.js

Try to prevent simple mistakes.