From 9b0b9b694415d42a379716dd5759283b649b5b5f Mon Sep 17 00:00:00 2001 From: 4gray Date: Tue, 29 Sep 2026 21:20:09 +0200 Subject: [PATCH] perf(electron): compile the main process and preload for ES2022 apps/electron-backend/tsconfig.json now sets target ES2022, so the main-process bundles, the preloads and the backend's Jest specs no longer downlevel async/await, optional chaining and nullish coalescing for ES2015. Electron 43 runs them natively in the main process and in the sandboxed preload. tsconfig.base.json keeps es2015 because other projects inherit it. useDefineForClassFields stays false, so class fields keep their constructor assignment semantics and only syntax changes. main.js + main.app.js + deferred-events.js + main.preload.js shrink from 2,008,115 to 1,853,599 bytes (-7.7%); every inlined __awaiter helper is gone. Startup did not move measurably: main-process CPU to did-finish-load and the J1 launch journey were flat in interleaved A/B runs, with identical counters. Co-Authored-By: Claude Opus 5.5 --- apps/electron-backend/tsconfig.json | 4 +++- docs/development/electron-debugging.md | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/apps/electron-backend/tsconfig.json b/apps/electron-backend/tsconfig.json index 522574b2b..0d3637e7d 100644 --- a/apps/electron-backend/tsconfig.json +++ b/apps/electron-backend/tsconfig.json @@ -4,7 +4,9 @@ "types": ["node"], "moduleResolution": "nodenext", "module": "NodeNext", - "ignoreDeprecations": "6.0" + "ignoreDeprecations": "6.0", + "target": "ES2022", + "useDefineForClassFields": false }, "include": ["**/*.ts"] } diff --git a/docs/development/electron-debugging.md b/docs/development/electron-debugging.md index f4c594095..4ee34e510 100644 --- a/docs/development/electron-debugging.md +++ b/docs/development/electron-debugging.md @@ -134,3 +134,17 @@ from `app.asar`. The preload is [workspace shell](../architecture/workspace-shell.md) for window behavior, [DB worker](../architecture/sqlite-db-worker.md) for worker ownership and [Electron security](../architecture/electron-security.md) for bridge boundaries. + +`apps/electron-backend/tsconfig.json` sets `"target": "ES2022"` for the +main-process bundles (`main.js`, `main.app.js`, `deferred-events.js`), the +preloads and the backend's Jest specs; `tsconfig.base.json` stays at `es2015` +because other projects inherit it. Electron 43 (Node 24 and Chromium's V8) runs +ES2022 natively in the main process and in the sandboxed preload, so +async/await, optional chaining and `??` are no longer downleveled. +`"useDefineForClassFields": false` keeps the class-field semantics of the old +target (constructor assignment, not `[[Define]]`), so only syntax changed. The +workers built by `build-worker.js` (esbuild, `node18`) were already native. On +2026-09-29 the four bundles shrank from 2,008,115 to 1,853,599 bytes (every +inlined `__awaiter` gone); neither main-process CPU time to `did-finish-load` +nor the J1 launch journey's wall-clock changed measurably in an interleaved +A/B, and J1's counters were identical.