| 196 | }; |
| 197 | |
| 198 | const clearModulesCache = () => { |
| 199 | // the fs locations where user plugins are stored |
| 200 | const {path, localPath} = plugins.getBasePaths(); |
| 201 | |
| 202 | // trigger unload hooks |
| 203 | modules.forEach((mod) => { |
| 204 | if (mod.onRendererUnload) { |
| 205 | // eslint-disable-next-line @typescript-eslint/no-unsafe-call |
| 206 | mod.onRendererUnload(window); |
| 207 | } |
| 208 | }); |
| 209 | |
| 210 | // clear require cache |
| 211 | for (const entry in window.require.cache) { |
| 212 | if (entry.indexOf(path) === 0 || entry.indexOf(localPath) === 0) { |
| 213 | // `require` is webpacks', `window.require` is electron's |
| 214 | delete window.require.cache[entry]; |
| 215 | } |
| 216 | } |
| 217 | }; |
| 218 | |
| 219 | const pathModule = window.require('path') as typeof import('path'); |
| 220 | |