fix some bugs in hmr-wrapper