diff options
author | Vendicated <vendicated@riseup.net> | 2022-11-03 20:36:17 +0100 |
---|---|---|
committer | Vendicated <vendicated@riseup.net> | 2022-11-03 20:36:17 +0100 |
commit | 65620f4976ad88967a8b64792fed5b0667f8e487 (patch) | |
tree | 74d549d537fc7ab97e2379e64452977f3309d3d3 /src/webpack | |
parent | cb7469afad37e0aea53dd9d5fbd21920eb3f2f3a (diff) | |
download | Vencord-65620f4976ad88967a8b64792fed5b0667f8e487.tar.gz Vencord-65620f4976ad88967a8b64792fed5b0667f8e487.tar.bz2 Vencord-65620f4976ad88967a8b64792fed5b0667f8e487.zip |
Webpack: Do not emit errors if devtools open
Diffstat (limited to 'src/webpack')
-rw-r--r-- | src/webpack/webpack.ts | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/src/webpack/webpack.ts b/src/webpack/webpack.ts index ba2d559..4f78f73 100644 --- a/src/webpack/webpack.ts +++ b/src/webpack/webpack.ts @@ -66,6 +66,14 @@ export function _initWebpack(instance: typeof window.webpackChunkdiscord_app) { instance.pop(); } +if (IS_DEV && !IS_WEB) { + var devToolsOpen = false; + // At this point in time, DiscordNative has not been exposed yet, so setImmediate is needed + setTimeout(() => { + DiscordNative/* just to make sure */?.window.setDevtoolsCallbacks(() => devToolsOpen = true, () => devToolsOpen = false); + }, 0); +} + export function find(filter: FilterFn, getDefault = true, isWaitFor = false) { if (typeof filter !== "function") throw new Error("Invalid filter. Expected a function got " + typeof filter); @@ -92,10 +100,12 @@ export function find(filter: FilterFn, getDefault = true, isWaitFor = false) { if (!isWaitFor) { const err = new Error("Didn't find module matching this filter"); if (IS_DEV) { - // Strict behaviour in DevBuilds to fail early and make sure the issue is found - throw err; + if (!devToolsOpen) + // Strict behaviour in DevBuilds to fail early and make sure the issue is found + throw err; + } else { + logger.warn(err); } - logger.warn(err); } return null; @@ -196,10 +206,12 @@ export function bulk(...filterFns: FilterFn[]) { if (found !== length) { const err = new Error(`Got ${length} filters, but only found ${found} modules!`); if (IS_DEV) { - // Strict behaviour in DevBuilds to fail early and make sure the issue is found - throw err; + if (!devToolsOpen) + // Strict behaviour in DevBuilds to fail early and make sure the issue is found + throw err; + } else { + logger.warn(err); } - logger.warn(err); } return results; @@ -219,10 +231,12 @@ export function findModuleId(code: string) { const err = new Error("Didn't find module with code:\n" + code); if (IS_DEV) { - // Strict behaviour in DevBuilds to fail early and make sure the issue is found - throw err; + if (!devToolsOpen) + // Strict behaviour in DevBuilds to fail early and make sure the issue is found + throw err; + } else { + logger.warn(err); } - logger.warn(err); return null; } |