Skip to content

[Tech] Make it possible to disable the React developer tools #1895

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,8 @@ To do that, open up the command palette (Ctrl + P), type in "task" and press Spa
If you want to quickly test a change, or you're implementing features that require a lot of restarts, you can use Vite's development server to speed up the process:
Go to the "Run and Debug" tab of VSCode and start the "Launch Heroic (HMR & HR)" task (alternatively, if you're not using VSCode or just prefer the terminal, run `yarn dev`). Heroic will start up after a short while, and once you make any change to the code, it'll reload/restart.

Note: If you do not need the React developer tools while testing changes, you can skip their install by setting the `HEROIC_NO_REACT_DEVTOOLS` environment variable before running `yarn dev` (for example with `HEROIC_NO_REACT_DEVTOOLS=1 yarn dev`).

### Development Using a Container

<details>
Expand Down
18 changes: 10 additions & 8 deletions src/backend/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,15 +235,17 @@ async function createWindow(): Promise<BrowserWindow> {
}

if (!app.isPackaged) {
/* eslint-disable @typescript-eslint/ban-ts-comment */
//@ts-ignore
import('electron-devtools-installer').then((devtools) => {
const { default: installExtension, REACT_DEVELOPER_TOOLS } = devtools
if (!process.env.HEROIC_NO_REACT_DEVTOOLS) {
import('electron-devtools-installer').then((devtools) => {
const { default: installExtension, REACT_DEVELOPER_TOOLS } = devtools

installExtension(REACT_DEVELOPER_TOOLS).catch((err: string) => {
logWarning(['An error occurred: ', err], { prefix: LogPrefix.Backend })
installExtension(REACT_DEVELOPER_TOOLS).catch((err: string) => {
logWarning(['An error occurred: ', err], {
prefix: LogPrefix.Backend
})
})
})
})
}
mainWindow.loadURL('http://localhost:5173')
// Open the DevTools.
mainWindow.webContents.openDevTools()
Expand Down Expand Up @@ -779,7 +781,7 @@ ipcMain.handle(
}

try {
// @ts-ignore This is actually fine as long as the frontend always passes the right InstallPlatform for the right runner
// @ts-expect-error This is actually fine as long as the frontend always passes the right InstallPlatform for the right runner
const info = await getGame(game, runner).getInstallInfo(installPlatform)
return info
} catch (error) {
Expand Down