Use require.register instead of window.require.register.
Refactor compiling.