Skip to content

Commit f1ee3eb

Browse files
committed
🤖 fix: restore React DevTools by reverting to dynamic import
The refactor in a55417a changed from using dynamic import() inside app.whenReady() to using require() at module load time. This broke React DevTools because electron-devtools-installer accesses Electron APIs that aren't available until the app is ready. Reverted to the working approach from commit 1e08943 that uses await import() inside the app.whenReady() handler. _Generated with `mux`_
1 parent 5baa5db commit f1ee3eb

File tree

1 file changed

+5
-28
lines changed

1 file changed

+5
-28
lines changed

src/desktop/main.ts

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -25,33 +25,7 @@ import assert from "@/common/utils/assert";
2525
import { loadTokenizerModules } from "@/node/utils/main/tokenizer";
2626

2727
// React DevTools for development profiling
28-
// Using require() instead of import since it's dev-only and conditionally loaded
29-
interface Extension {
30-
name: string;
31-
id: string;
32-
}
33-
34-
type ExtensionInstaller = (
35-
ext: { id: string },
36-
options?: { loadExtensionOptions?: { allowFileAccess?: boolean } }
37-
) => Promise<Extension>;
38-
39-
let installExtension: ExtensionInstaller | null = null;
40-
let REACT_DEVELOPER_TOOLS: { id: string } | null = null;
41-
42-
if (!app.isPackaged) {
43-
try {
44-
// eslint-disable-next-line @typescript-eslint/no-require-imports
45-
const devtools = require("electron-devtools-installer") as {
46-
default: ExtensionInstaller;
47-
REACT_DEVELOPER_TOOLS: { id: string };
48-
};
49-
installExtension = devtools.default;
50-
REACT_DEVELOPER_TOOLS = devtools.REACT_DEVELOPER_TOOLS;
51-
} catch (error) {
52-
console.log("React DevTools not available:", error);
53-
}
54-
}
28+
// Using dynamic import() to avoid loading electron-devtools-installer at module init time
5529

5630
// IMPORTANT: Lazy-load heavy dependencies to maintain fast startup time
5731
//
@@ -509,8 +483,11 @@ if (gotTheLock) {
509483
migrateLegacyMuxHome();
510484

511485
// Install React DevTools in development
512-
if (!app.isPackaged && installExtension && REACT_DEVELOPER_TOOLS) {
486+
if (!app.isPackaged) {
513487
try {
488+
const { default: installExtension, REACT_DEVELOPER_TOOLS } = await import(
489+
"electron-devtools-installer"
490+
);
514491
const extension = await installExtension(REACT_DEVELOPER_TOOLS, {
515492
loadExtensionOptions: { allowFileAccess: true },
516493
});

0 commit comments

Comments
 (0)