mirror of
https://github.com/Equicord/Equicord.git
synced 2025-06-18 02:47:03 -04:00
Path aliases, better lazyWebpack (#268)
This commit is contained in:
parent
7a4402f142
commit
bad96b7887
138 changed files with 572 additions and 547 deletions
|
@ -16,11 +16,11 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import Logger from "@utils/Logger";
|
||||
import { proxyLazy } from "@utils/proxyLazy";
|
||||
import type { WebpackInstance } from "discord-types/other";
|
||||
|
||||
import { traceFunction } from "../debug/Tracer";
|
||||
import Logger from "../utils/Logger";
|
||||
import { proxyLazy } from "../utils/proxyLazy";
|
||||
|
||||
const logger = new Logger("Webpack");
|
||||
|
||||
|
@ -113,6 +113,13 @@ export const find = traceFunction("find", function find(filter: FilterFn, getDef
|
|||
return null;
|
||||
});
|
||||
|
||||
/**
|
||||
* find but lazy
|
||||
*/
|
||||
export function findLazy(filter: FilterFn, getDefault = true) {
|
||||
return proxyLazy(() => find(filter, getDefault));
|
||||
}
|
||||
|
||||
export function findAll(filter: FilterFn, getDefault = true) {
|
||||
if (typeof filter !== "function")
|
||||
throw new Error("Invalid filter. Expected a function got " + typeof filter);
|
||||
|
@ -291,6 +298,13 @@ export function findByProps(...props: string[]) {
|
|||
return find(filters.byProps(...props));
|
||||
}
|
||||
|
||||
/**
|
||||
* findByProps but lazy
|
||||
*/
|
||||
export function findByPropsLazy(...props: string[]) {
|
||||
return findLazy(filters.byProps(...props));
|
||||
}
|
||||
|
||||
/**
|
||||
* Find all modules that have the specified properties
|
||||
*/
|
||||
|
@ -305,6 +319,13 @@ export function findByCode(...code: string[]) {
|
|||
return find(filters.byCode(...code));
|
||||
}
|
||||
|
||||
/**
|
||||
* findByCode but lazy
|
||||
*/
|
||||
export function findByCodeLazy(...code: string[]) {
|
||||
return findLazy(filters.byCode(...code));
|
||||
}
|
||||
|
||||
/**
|
||||
* Wait for a module that matches the provided filter to be registered,
|
||||
* then call the callback with the module as the first argument
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue