mirror of
https://github.com/Equicord/Equicord.git
synced 2025-06-10 07:03:06 -04:00
Clean up circular imports fixes
This commit is contained in:
parent
d542095993
commit
8c7225d106
3 changed files with 33 additions and 22 deletions
|
@ -24,16 +24,20 @@ export const Menu = {} as t.Menu;
|
|||
|
||||
// Relies on .name properties added by the MenuItemDemanglerAPI
|
||||
waitFor(m => m.name === "MenuCheckboxItem", (_, id) => {
|
||||
// we have to do this manual require by ID because m is in this case the MenuCheckBoxItem instead of the entire module
|
||||
const module = wreq(id);
|
||||
// We have to do this manual require by ID because m in this case is the MenuCheckBoxItem instead of the entire module
|
||||
const exports = wreq(id);
|
||||
|
||||
for (const key in module) {
|
||||
for (const exportKey in exports) {
|
||||
// Some exports might have not been initialized yet due to circular imports, so try catch it.
|
||||
try {
|
||||
const e = module[key];
|
||||
if (typeof e === "function" && e.name.startsWith("Menu")) {
|
||||
Menu[e.name] = e;
|
||||
}
|
||||
} catch { }
|
||||
var exportValue = exports[exportKey];
|
||||
} catch {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (typeof exportValue === "function" && exportValue.name.startsWith("Menu")) {
|
||||
Menu[exportValue.name] = exportValue;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -412,12 +412,9 @@ function runFactoryWithWrap(patchedFactory: PatchedModuleFactory, thisArg: unkno
|
|||
exports = module.exports;
|
||||
|
||||
if (typeof require === "function" && require.c) {
|
||||
// module might not have been fully initialised yet
|
||||
try {
|
||||
if (_blacklistBadModules(require.c, exports, module.id)) {
|
||||
return factoryReturn;
|
||||
}
|
||||
} catch { }
|
||||
if (_blacklistBadModules(require.c, exports, module.id)) {
|
||||
return factoryReturn;
|
||||
}
|
||||
}
|
||||
|
||||
if (exports == null) {
|
||||
|
@ -445,15 +442,18 @@ function runFactoryWithWrap(patchedFactory: PatchedModuleFactory, thisArg: unkno
|
|||
}
|
||||
|
||||
for (const exportKey in exports) {
|
||||
// Some exports might have not been initialized yet due to circular imports, so try catch it.
|
||||
try {
|
||||
const exportValue = exports[exportKey];
|
||||
var exportValue = exports[exportKey];
|
||||
} catch {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (exportValue != null && filter(exportValue)) {
|
||||
waitForSubscriptions.delete(filter);
|
||||
callback(exportValue, module.id);
|
||||
break;
|
||||
}
|
||||
} catch { }
|
||||
if (exportValue != null && filter(exportValue)) {
|
||||
waitForSubscriptions.delete(filter);
|
||||
callback(exportValue, module.id);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
logger.error("Error while firing callback for Webpack waitFor subscription:\n", err, filter, callback);
|
||||
|
|
|
@ -156,7 +156,14 @@ export function _blacklistBadModules(requireCache: NonNullable<AnyWebpackRequire
|
|||
|
||||
let hasOnlyBadProperties = true;
|
||||
for (const exportKey in exports) {
|
||||
if (shouldIgnoreValue(exports[exportKey])) {
|
||||
// Some exports might have not been initialized yet due to circular imports, so try catch it.
|
||||
try {
|
||||
var exportValue = exports[exportKey];
|
||||
} catch {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (shouldIgnoreValue(exportValue)) {
|
||||
makePropertyNonEnumerable(exports, exportKey);
|
||||
} else {
|
||||
hasOnlyBadProperties = false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue