Skip to content

Commit 7f4374d

Browse files
authored
fix: type declarations not found and invalid require usage in ESM build (#276)
* fix: type declarations not found * docs: limitations and conditional installation of devtron * fix: invalid require usage in ESM build * docs: add bullet point * chore: simplify externals config in webpack * docs: fix typo * chore: remove `main` and `module` fields from package.json * docs: clarify IPC events not tracked at app startup * docs: minor wording fix * docs: use app.isPackaged instead of hardcoded isDev flag
1 parent 032f590 commit 7f4374d

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed

README.md

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,39 @@
1616
- In your Electron app's `main.js` (or other relevant file) add the following code to load Devtron:
1717

1818
```js
19-
//main.js
19+
// main.js
2020
const { devtron } = require('@electron/devtron');
2121
// or import { devtron } from '@electron/devtron'
2222

2323
devtron.install(); // call this function at the top of your file
2424
```
2525

26+
- Devtron can be conditionally installed in **development mode** to avoid impacting production builds. Here's an example:
27+
28+
```js
29+
const { app } = require('electron');
30+
31+
const isDev = !app.isPackaged;
32+
33+
async function installDevtron() {
34+
const { devtron } = await import('@electron/devtron');
35+
await devtron.install();
36+
}
37+
38+
if (isDev) {
39+
installDevtron().catch((error) => {
40+
console.error('Failed to install Devtron:', error);
41+
});
42+
}
43+
```
44+
45+
## Requirements and Limitations
46+
47+
- Electron version must be 36.0.0 or higher.
48+
- For Devtron to work with newly created **sessions**, you must call `devtron.install()` before they are created.
49+
- Some IPC events sent immediately after the Electron app starts may not be captured by Devtron, even if `devtron.install()` is called early, because Devtron may take a short time to initialize after starting the app.
50+
- `ipcRenderer.once` will be tracked as two separate events: `ipcRenderer.on` and `ipcRenderer.removeListener`.
51+
2652
If Devtron is installed correctly, it should appear as a tab in the Developer Tools of your Electron app.
2753

2854
<img src="https://github.com/user-attachments/assets/0f278b54-50fe-4116-9317-9c1525bf872b" width="800">

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"name": "@electron/devtron",
33
"version": "0.0.0-development",
44
"description": "Electron DevTools Extension to track IPC events",
5+
"types": "./dist/types/index.d.ts",
56
"exports": {
67
".": {
78
"import": "./dist/mjs/index.mjs",

webpack.node.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const commonConfig: Configuration = {
3131
extensions: ['.ts', '.tsx', '.js', '.jsx'],
3232
},
3333
externals: {
34-
electron: 'commonjs2 electron',
34+
electron: 'electron',
3535
},
3636
};
3737

0 commit comments

Comments
 (0)