diff --git a/src/utils/lazyReact.tsx b/src/utils/lazyReact.tsx index ff90179b6..484b1ddcb 100644 --- a/src/utils/lazyReact.tsx +++ b/src/utils/lazyReact.tsx @@ -17,7 +17,7 @@ export const SYM_LAZY_COMPONENT_INNER = Symbol.for("vencord.lazyComponent.inner" * @param attempts How many times to try to get the component before giving up * @returns Result of factory function */ -export function LazyComponent(factory: () => LazyComponentType, attempts = 5) { +export function LazyComponent(factory: () => LazyComponentType, attempts = 5, errMsg: string | (() => string) = `LazyComponent factory failed:\n\n${factory}`) { const get = makeLazy(factory, attempts, { isIndirect: true }); let InnerComponent = null as LazyComponentType | null; @@ -37,7 +37,7 @@ export function LazyComponent(factory: () => LazyCompone lazyFailedLogged = true; } - console.error(`LazyComponent factory failed:\n\n${factory}`); + console.error(typeof errMsg === "string" ? errMsg : errMsg()); } return InnerComponent && ; diff --git a/src/webpack/api.tsx b/src/webpack/api.tsx index ef74eb285..5ca60ff42 100644 --- a/src/webpack/api.tsx +++ b/src/webpack/api.tsx @@ -588,7 +588,7 @@ export function webpackDependantLazy(factory: () => T, attempts?: numbe export function webpackDependantLazyComponent(factory: () => any, attempts?: number) { if (IS_REPORTER) webpackSearchHistory.push(["webpackDependantLazyComponent", [factory]]); - return LazyComponent(factory, attempts); + return LazyComponent(factory, attempts, `Webpack dependant LazyComponent factory failed:\n\n${factory}`); } export const DefaultExtractAndLoadChunksRegex = /(?:(?:Promise\.all\(\[)?(\i\.e\("?[^)]+?"?\)[^\]]*?)(?:\]\))?|Promise\.resolve\(\))\.then\(\i\.bind\(\i,"?([^)]+?)"?\)\)/;