enten / udk

Universal Development Kit: Webpack extension which improves universal application development. - THE UDK PROJECT SUPPORT IS CURRENTLY SUSPENDED.
MIT License
29 stars 7 forks source link

MultiCompiler: fix HMR on server side for webpack4 #3

Closed enten closed 6 years ago

enten commented 6 years ago

Source of the issue : lib/MultiCompiler.js

HMR on server side is broken for webpack4 when the server bundle hot reload a file which was already hot reloaded by a bundle dependency.

The event which hold hot updates is lost during waiting time.

Server Bundle ---> Shared Module <-- Client Bundle
      |                                    ^
      +------------------------------------+
  udk:client:cpl null invalid +3s
webpack building...
  udk:server:cpl null invalid +3s
webpack building...
  udk:client:cpl 8 watchRun +204ms
  udk:client:cpl 9 normalModuleFactory +1ms
  udk:client:cpl 10 contextModuleFactory +1ms
  udk:client:cpl 11 beforeCompile +0ms
  udk:client:cpl 12 compile +0ms
  udk:client:cpl 13 thisCompilation +1ms
  udk:client:cpl 14 compilation +1ms
  udk:client:cpl 15 make +2ms
  udk:server:cpl 8 watchRun +213ms
  udk:server:cpl wait for compiler 'client' +0ms
  udk:client:cpl 16 afterCompile +23ms
  udk:client:cpl 17 shouldEmit +0ms
  udk:client:cpl 19 emit +0ms
  udk:client:cpl 20 afterEmit +2ms
  udk:ctnr:fork update client stats +3s
  udk:client:cpl 21 done +3ms
  udk:server:cpl waiting ended for compiler 'client' +25ms
  udk:client:cpl invalid compiler 'server' due to change { fileName: '/home/steven/code/udk/examples/basic/src/shared.js', changeTime: 1522507183373 } +1ms
  udk:server:cpl null invalid +0ms
webpack building...
  udk:ctnr:fork compiler watching +4ms
  udk:server:cpl 9 normalModuleFactory +6ms
  udk:server:cpl 10 contextModuleFactory +0ms
  udk:server:cpl 11 beforeCompile +0ms
  udk:server:cpl 12 compile +1ms
  udk:server:cpl 13 thisCompilation +0ms
  udk:server:cpl 14 compilation +1ms
  udk:server:cpl 15 make +0ms
  udk:server:cpl 16 afterCompile +13ms
  udk:server:cpl 8 watchRun +0ms
  udk:server:cpl 9 normalModuleFactory +1ms
  udk:server:cpl 10 contextModuleFactory +0ms
  udk:server:cpl 11 beforeCompile +0ms
  udk:server:cpl 12 compile +0ms
  udk:server:cpl 13 thisCompilation +0ms
  udk:server:cpl 14 compilation +1ms
  udk:server:cpl 15 make +0ms
  udk:server:cpl 16 afterCompile +7ms
  udk:server:cpl 17 shouldEmit +0ms
  udk:server:cpl 19 emit +0ms
  udk:server:cpl 20 afterEmit +2ms
  udk:server:cpl 21 done +1ms
webpack built client e923e801f199865a2b0b in 31ms
webpack built server f920487f814020a1421a in 12ms
  udk:ctnr:fork compiler watching +37ms