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
4 changed files with 455 additions and 150 deletions

View File

@@ -20,12 +20,24 @@ const mermaidIIFEConfig = getBuildConfig({
}); });
configs.push(mermaidIIFEConfig); 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 () => { const rebuildAll = async () => {
console.time('Rebuild time'); const buildNumber = rebuildCounter++;
await Promise.all(contexts.map((ctx) => ctx.rebuild())).catch((e) => console.error(e)); const timeLabel = `Rebuild ${buildNumber} Time (total)`;
console.timeEnd('Rebuild time'); 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 }[] = []; 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. * Debounce file change events to avoid rebuilding multiple times.
*/ */
function handleFileChange() { function handleFileChange() {
if (timeoutId !== undefined) { if (timeoutID !== undefined) {
clearTimeout(timeoutId); clearTimeout(timeoutID);
} }
// eslint-disable-next-line @typescript-eslint/no-misused-promises // eslint-disable-next-line @typescript-eslint/no-misused-promises
timeoutId = setTimeout(async () => { timeoutID = setTimeout(async () => {
await rebuildAll(); await rebuildAll();
sendEventsToAll(); sendEventsToAll();
timeoutId = undefined; timeoutID = undefined;
}, 100); }, 100);
} }
@@ -82,10 +94,11 @@ async function createServer() {
if (!['add', 'change'].includes(event)) { if (!['add', 'change'].includes(event)) {
return; return;
} }
console.log(`${path} changed. Rebuilding...`);
if (/\.langium$/.test(path)) { if (/\.langium$/.test(path)) {
await generateLangium(); await generateLangium();
} }
console.log(`${path} changed. Rebuilding...`);
handleFileChange(); handleFileChange();
}); });

View File

@@ -86,7 +86,7 @@
"cspell": "^8.6.0", "cspell": "^8.6.0",
"cypress": "^13.7.1", "cypress": "^13.7.1",
"cypress-image-snapshot": "^4.0.1", "cypress-image-snapshot": "^4.0.1",
"esbuild": "^0.20.2", "esbuild": "^0.21.5",
"eslint": "^9.4.0", "eslint": "^9.4.0",
"eslint-config-prettier": "^9.1.0", "eslint-config-prettier": "^9.1.0",
"eslint-plugin-cypress": "^3.3.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", "groupSlug": "all-patch",
"matchPackagePatterns": ["*"], "matchPackagePatterns": ["*"],
"matchUpdateTypes": ["patch"] "matchUpdateTypes": ["patch"]
},
{
"groupName": "eslint",
"matchPackagePatterns": ["eslint"]
} }
], ],
"dependencyDashboard": false, "dependencyDashboard": false,