Skip to content

Improve watch mode dev scripts

Antoine requested to merge ZeHiro/kresus:watch-mode into master

This MR :

  • ensures the server is built befors starting the watch mode (commit 1). Without this, the following error is raised several times (as the server is restarded many times until the initial build is finished):
[2]     throw err;
[2]     ^
[2] 
[2] Error: Cannot find module '/home/tonio/Code/kresus/build/server/config.js'
[2] Require stack:
[2] - /home/tonio/Code/kresus/bin/kresus.js
[2]     at Function.Module._resolveFilename (internal/modules/cjs/loader.js:772:15)
[2]     at Function.Module._load (internal/modules/cjs/loader.js:677:27)
[2]     at Module.require (internal/modules/cjs/loader.js:830:19)
[2]     at require (internal/modules/cjs/helpers.js:68:18)
[2]     at Object.<anonymous> (/home/tonio/Code/kresus/bin/kresus.js:194:1)
[2]     at Module._compile (internal/modules/cjs/loader.js:936:30)
[2]     at Object.Module._extensions..js (internal/modules/cjs/loader.js:947:10)
[2]     at Module.load (internal/modules/cjs/loader.js:790:32)
[2]     at Function.Module._load (internal/modules/cjs/loader.js:703:12)
[2]     at Function.Module.runMain (internal/modules/cjs/loader.js:999:10) {
[2]   code: 'MODULE_NOT_FOUND',
[2]   requireStack: [ '/home/tonio/Code/kresus/bin/kresus.js' ]
[2] }
  • Configures the watch mode more precisely :
    • TSC_WATCHFILE=UseFsEventsWithFallbackDynamicPolling env variable optimizes number of recompiles triggered (more info here: https://www.typescriptlang.org/docs/handbook/configuring-watch.html)
    • incremental allows to only rebuild what is necessary, reducing the number of new files emitted, and thus the number of reboots of the server
    • preserveWatchOutput is to keep the stdin/stdout even after a watch rebuild (otherwise the console output is cleared)
Edited by Antoine

Merge request reports

Loading