Merge branch 'develop' into sidv/eslintv9

* develop:
  chore: Log granular rebuild times
  Separate eslint packages from updates
This commit is contained in:
Sidharth Vinod 2024-06-30 14:27:38 +05:30
commit c8a3290163
No known key found for this signature in database
GPG Key ID: FB5CCD378D3907CD
4 changed files with 455 additions and 150 deletions

View File

@ -20,12 +20,24 @@ const mermaidIIFEConfig = getBuildConfig({
});
configs.push(mermaidIIFEConfig);
const contexts = await Promise.all(configs.map((config) => context(config)));
const contexts = await Promise.all(
configs.map(async (config) => ({ config, context: await context(config) }))
);
let rebuildCounter = 1;
const rebuildAll = async () => {
console.time('Rebuild time');
await Promise.all(contexts.map((ctx) => ctx.rebuild())).catch((e) => console.error(e));
console.timeEnd('Rebuild time');
const buildNumber = rebuildCounter++;
const timeLabel = `Rebuild ${buildNumber} Time (total)`;
console.time(timeLabel);
await Promise.all(
contexts.map(async ({ config, context }) => {
const buildVariant = `Rebuild ${buildNumber} Time (${Object.keys(config.entryPoints!)[0]} ${config.format})`;
console.time(buildVariant);
await context.rebuild();
console.timeEnd(buildVariant);
})
).catch((e) => console.error(e));
console.timeEnd(timeLabel);
};
let clients: { id: number; response: Response }[] = [];
@ -46,20 +58,20 @@ function eventsHandler(request: Request, response: Response) {
});
}
let timeoutId: NodeJS.Timeout | undefined = undefined;
let timeoutID: NodeJS.Timeout | undefined = undefined;
/**
* Debounce file change events to avoid rebuilding multiple times.
*/
function handleFileChange() {
if (timeoutId !== undefined) {
clearTimeout(timeoutId);
if (timeoutID !== undefined) {
clearTimeout(timeoutID);
}
// eslint-disable-next-line @typescript-eslint/no-misused-promises
timeoutId = setTimeout(async () => {
timeoutID = setTimeout(async () => {
await rebuildAll();
sendEventsToAll();
timeoutId = undefined;
timeoutID = undefined;
}, 100);
}
@ -82,10 +94,11 @@ async function createServer() {
if (!['add', 'change'].includes(event)) {
return;
}
console.log(`${path} changed. Rebuilding...`);
if (/\.langium$/.test(path)) {
await generateLangium();
}
console.log(`${path} changed. Rebuilding...`);
handleFileChange();
});

View File

@ -86,7 +86,7 @@
"cspell": "^8.6.0",
"cypress": "^13.7.1",
"cypress-image-snapshot": "^4.0.1",
"esbuild": "^0.20.2",
"esbuild": "^0.21.5",
"eslint": "^9.4.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-cypress": "^3.3.0",

566
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@ -31,6 +31,10 @@
"groupSlug": "all-patch",
"matchPackagePatterns": ["*"],
"matchUpdateTypes": ["patch"]
},
{
"groupName": "eslint",
"matchPackagePatterns": ["eslint"]
}
],
"dependencyDashboard": false,