Skip to content
Source
Sign inSign up
pingdotgg/t3code

perf(desktop): cache compiled JavaScript between launches #13501

Mergedt3dotgg(GitHub profile, opens in a new tab)merged 6 commits intomain fromrefs/pull/13501/headmerged by t3dotgg(GitHub profile, opens in a new tab) View on GitHub

Showing 15 changed files with 67 additions and 1 deletion (loading 12).

x
0 of 15 viewed, 15 left
63 additions and 0 deletionsapps/desktop/scripts/main-process-bundle.test.mjsModified
View file
@@ -1,3 +1,4 @@
+import * as NodeChildProcess from "node:child_process";
import * as NodeFSP from "node:fs/promises";
import * as NodeOS from "node:os";
import * as NodePath from "node:path";
@@ -108,3 +109,65 @@
await NodeFSP.rm(directory, { recursive: true, force: true });
});
+​
+it("loads the emitted packaged boot entry and backend cache preload", async () => {
+ const directory = await NodeFSP.mkdtemp(NodePath.join(NodeOS.tmpdir(), "t3-desktop-boot-"));
+ try {
+ const entries = ["src/boot.ts", "src/compileCache.ts"];
+ await NodeFSP.mkdir(NodePath.join(directory, "src"));
+ await Promise.all(
+ entries.map((entry) =>
+ NodeFSP.copyFile(new URL(`../${entry}`, import.meta.url), NodePath.join(directory, entry)),
+ ),
+ );
+ assert.ok(Array.isArray(desktopConfig.pack));
+ for (const packConfig of desktopConfig.pack) {
+ if (!Array.isArray(packConfig.entry)) continue;
+ if (!packConfig.entry.some((entry) => entries.includes(entry))) continue;
+ await build({
+ ...packConfig,
+ config: false,
+ cwd: directory,
+ tsconfig: false,
+ sourcemap: false,