mirror of
https://github.com/dillonkearns/elm-pages-v3-beta.git
synced 2024-12-26 13:21:42 +03:00
Restart thread pool when Elm code changes to clear import cache.
This commit is contained in:
parent
3622c715ad
commit
2ecbc16eb9
@ -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",
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user