MCPcopy Index your code
hub / github.com/vercel/hyper / clearModulesCache

Function clearModulesCache

lib/utils/plugins.ts:198–217  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

196};
197
198const 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
219const pathModule = window.require('path') as typeof import('path');
220

Callers 1

reloadFunction · 0.85

Calls 2

indexOfMethod · 0.80
forEachMethod · 0.45

Tested by

no test coverage detected