give name to PatchedFactory

This commit is contained in:
Nuckyz 2024-05-28 03:57:56 -03:00
parent c9c09b95a3
commit acbc932542
No known key found for this signature in database
GPG key ID: 440BF8296E1C4AD9

View file

@ -327,8 +327,9 @@ function patchFactory(id: PropertyKey, factory: ModuleFactory) {
if (!patch.all) patches.splice(i--, 1);
}
// The patched factory wrapper
const patchedFactory: PatchedModuleFactory = function (...args: Parameters<ModuleFactory>) {
// The patched factory wrapper, define it in an object to preserve the name after minification
const patchedFactory: PatchedModuleFactory = {
PatchedFactory(...args: Parameters<ModuleFactory>) {
// Restore the original factory in all the module factories objects,
// because we want to make sure the original factory is restored properly, no matter what is the Webpack instance
for (const moduleFactories of allModuleFactories) {
@ -418,7 +419,8 @@ function patchFactory(id: PropertyKey, factory: ModuleFactory) {
}
return factoryReturn;
};
}
}.PatchedFactory;
patchedFactory.toString = originalFactory.toString.bind(originalFactory);
patchedFactory.$$vencordOriginal = originalFactory;