mirror of
https://github.com/dillonkearns/elm-pages-v3-beta.git
synced 2024-12-27 05:44:17 +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) {
|
export async function start(options) {
|
||||||
let threadReadyQueue = [];
|
let threadReadyQueue = [];
|
||||||
let pool = [];
|
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"));
|
ensureDirSync(path.join(process.cwd(), ".elm-pages", "http-response-cache"));
|
||||||
const cpuCount = os.cpus().length;
|
const cpuCount = os.cpus().length;
|
||||||
|
|
||||||
@ -252,6 +263,7 @@ export async function start(options) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
elmMakeRunning = true;
|
elmMakeRunning = true;
|
||||||
|
restartPool();
|
||||||
if (codegenError) {
|
if (codegenError) {
|
||||||
const errorJson = JSON.stringify({
|
const errorJson = JSON.stringify({
|
||||||
type: "compile-errors",
|
type: "compile-errors",
|
||||||
|
@ -43,11 +43,6 @@ async function run({ mode, pathname, serverRequest, portsFilePath }) {
|
|||||||
|
|
||||||
async function requireElm(mode) {
|
async function requireElm(mode) {
|
||||||
let elmImportPath = compiledElmPath;
|
let elmImportPath = compiledElmPath;
|
||||||
if (mode !== "build") {
|
|
||||||
const { mtimeMs } = await stat(compiledElmPath);
|
|
||||||
console.log({ mtimeMs });
|
|
||||||
elmImportPath = `${compiledElmPath}?time=${mtimeMs}`;
|
|
||||||
}
|
|
||||||
const warnOriginal = console.warn;
|
const warnOriginal = console.warn;
|
||||||
console.warn = function () {};
|
console.warn = function () {};
|
||||||
const Elm = (await import(elmImportPath)).default;
|
const Elm = (await import(elmImportPath)).default;
|
||||||
|
Loading…
Reference in New Issue
Block a user