isDev is always true
licarth opened this issue · 4 comments
electron-is-dev
's isDev
variable is always true.
The problem seems to be in the way isDev
is imported.
Instead of
import * as isDev from "electron-is-dev";
Using the following will solve the issue:
import isDev from "electron-is-dev";
@licarth, thank you for the report. If I change the line in main.ts accordingly and run yarn electron:dev
, then I got the following errors...
11:00:21 AM - Starting compilation in watch mode...
[1]
[2] electron/main.ts(3,8): error TS1259: Module '"/Users/yhirose/Projects/react-typescript-electron-sample/node_modules/electron-is-dev/index"' can only be default-imported using the 'esModuleInterop' flag
[2] wait-on http://localhost:3000 && tsc -p electron && electron . exited with code 1
[1] electron/main.ts(3,8): error TS1259: Module '"/Users/yhirose/Projects/react-typescript-electron-sample/node_modules/electron-is-dev/index"' can only be default-imported using the 'esModuleInterop' flag
[1]
[1] 11:00:23 AM - Found 1 error. Watching for file changes.
Yup, I faced the same problem, indeed. I had to add the esModuleInterop: true
flag to my tsconfig.json
. Anything against adding it ?
Because currently, yarn electron:build
does not work properly on my machine without fixing the import: it builds a bundle for production with isDev
returning true
.
@licarth, I built a production package with yarn electron:build
with the current code base, but isDev
gives me false
successfully on my Mac OS. (I confirmed the app doesn't show the DevTools window when the app starts.)
I just wonder why the problem happens on your machine, but on my machine... Does my environment miss something?
Alright, my bad. Just checked out your project, tried to reproduce and could not. Let's close this, I'll try to find out why it's like that on my project, which I created from your recipe (I do have a slightly different tsconfig).
Sorry again, and thanks for having looked into it.