electron/electron-quick-start-typescript

electron-reload typescript compiled to a wrong object ( to be electronReload['default'])

hcklawrence opened this issue · 1 comments

I am trying to learn typescript with electron a bit, using a template "electron-quick-start-typescript" (https://github.com/electron/electron-quick-start-typescript). I want to add a hot reload function to the template so I could hot reload while editing the code. I am trying to add

import electronReload from "electron-reload";
electronReload(__dirname, {});

these two lines of code, but after the compilation it became

var electron_reload_1 = require("electron-reload");
(0, electron_reload_1["default"])(__dirname, {});

where electron_reload_1["default"] cannot be recognised. I can run the compiled js while I manually changed electron_reload_1["default"] to electron_reload_1.

I guess the problem is because in electron-reload lib, it is not using export default module to export a function. Does anyone has experience on making typescript + electron hot reloadable? Thank you.

I just found that adding "esModuleInterop": true in tsconfig.json would solve this problem.