fix canary

This commit is contained in:
Vendicated 2025-02-16 21:57:14 +01:00
parent 8dfbb5f9d8
commit 71ddc4f1fc
No known key found for this signature in database
GPG key ID: D66986BAF75ECF18

View file

@ -112,6 +112,10 @@ export function _initWebpack(webpackRequire: WebpackRequire) {
// Credits to Zerebos for implementing this in BD, thus giving the idea for us to implement it too // Credits to Zerebos for implementing this in BD, thus giving the idea for us to implement it too
const TypedArray = Object.getPrototypeOf(Int8Array); const TypedArray = Object.getPrototypeOf(Int8Array);
// Discord might export a Proxy that returns non-null values for any property key (e.g. their i18n Proxy)
// We can use a unique symbol to detect this and ignore it
const uniqueSymbol = Symbol("matchesLiterallyAnything");
function _shouldIgnoreValue(value: any) { function _shouldIgnoreValue(value: any) {
if (value == null) return true; if (value == null) return true;
if (value === window) return true; if (value === window) return true;
@ -127,13 +131,22 @@ export function _shouldIgnoreModule(exports: any) {
return true; return true;
} }
if (typeof exports !== "object") { if (typeof exports !== "object" || exports == null) {
return false; return false;
} }
if (exports?.[uniqueSymbol]) {
return true;
}
let allNonEnumerable = true; let allNonEnumerable = true;
for (const exportKey in exports) { for (const exportKey in exports) {
if (!_shouldIgnoreValue(exports[exportKey])) { const exp = exports[exportKey];
if (exp?.[uniqueSymbol]) {
return true;
}
if (!_shouldIgnoreValue(exp)) {
allNonEnumerable = false; allNonEnumerable = false;
} }
} }