diff --git a/generator/src/dev-server.js b/generator/src/dev-server.js index f237ba59..ac526f90 100644 --- a/generator/src/dev-server.js +++ b/generator/src/dev-server.js @@ -40,6 +40,17 @@ const __dirname = path.dirname(__filename); export async function start(options) { let threadReadyQueue = []; let pool = []; + + function restartPool() { + pool.forEach((thread) => thread.worker.terminate()); + const poolSize = Math.max(1, cpuCount / 2 - 1); + pool = []; + + for (let index = 0; index < poolSize; index++) { + pool.push(initWorker(options.base)); + } + } + ensureDirSync(path.join(process.cwd(), ".elm-pages", "http-response-cache")); const cpuCount = os.cpus().length; @@ -252,6 +263,7 @@ export async function start(options) { } } elmMakeRunning = true; + restartPool(); if (codegenError) { const errorJson = JSON.stringify({ type: "compile-errors", diff --git a/generator/src/render-worker.js b/generator/src/render-worker.js index dc4ed229..4531478d 100644 --- a/generator/src/render-worker.js +++ b/generator/src/render-worker.js @@ -43,11 +43,6 @@ async function run({ mode, pathname, serverRequest, portsFilePath }) { async function requireElm(mode) { let elmImportPath = compiledElmPath; - if (mode !== "build") { - const { mtimeMs } = await stat(compiledElmPath); - console.log({ mtimeMs }); - elmImportPath = `${compiledElmPath}?time=${mtimeMs}`; - } const warnOriginal = console.warn; console.warn = function () {}; const Elm = (await import(elmImportPath)).default;