Add wreq.j
This commit is contained in:
parent
24a0f62801
commit
066001c57a
|
@ -85,6 +85,7 @@ function makeShortcuts() {
|
|||
wpex: extract,
|
||||
wpexs: (code: string) => extract(findModuleId(code)!),
|
||||
loadLazyChunks: IS_DEV ? loadLazyChunks : () => { throw new Error("loadLazyChunks is dev only."); },
|
||||
filters,
|
||||
find,
|
||||
findAll: findAll,
|
||||
findByProps,
|
||||
|
|
|
@ -453,14 +453,14 @@ export function findExportedComponentLazy<T extends object = any>(...props: stri
|
|||
* closeModal: filters.byCode("key==")
|
||||
* })
|
||||
*/
|
||||
export const mapMangledModule = traceFunction("mapMangledModule", function mapMangledModule<S extends string>(code: string, mappers: Record<S, FilterFn>): Record<S, any> {
|
||||
const exports = {} as Record<S, any>;
|
||||
export const mapMangledModule = traceFunction("mapMangledModule", function mapMangledModule<S extends string>(code: string, mappers: Record<S, FilterFn>): Record<S, ModuleExports> {
|
||||
const exports = {} as Record<S, ModuleExports>;
|
||||
|
||||
const id = findModuleId(code);
|
||||
if (id === null)
|
||||
return exports;
|
||||
|
||||
const mod = wreq(id as any);
|
||||
const mod = wreq(id);
|
||||
outer:
|
||||
for (const key in mod) {
|
||||
const member = mod[key];
|
||||
|
|
32
src/webpack/wreq.d.ts
vendored
32
src/webpack/wreq.d.ts
vendored
|
@ -58,21 +58,21 @@ export type WebpackRequire = ((moduleId: PropertyKey) => ModuleExports) & {
|
|||
m: Record<PropertyKey, ModuleFactory>;
|
||||
/** The module cache, where all modules which have been WebpackRequire'd are stored */
|
||||
c: Record<PropertyKey, Module>;
|
||||
/**
|
||||
* Export star. Sets properties of "fromObject" to "toObject" as getters that return the value from "fromObject", like this:
|
||||
* @example
|
||||
* const fromObject = { a: 1 };
|
||||
* Object.keys(fromObject).forEach(key => {
|
||||
* if (key !== "default" && !Object.hasOwn(toObject, key)) {
|
||||
* Object.defineProperty(toObject, key, {
|
||||
* get: () => fromObject[key],
|
||||
* enumerable: true
|
||||
* });
|
||||
* }
|
||||
* });
|
||||
* @returns fromObject
|
||||
*/
|
||||
es: (this: WebpackRequire, fromObject: Record<PropertyKey, any>, toObject: Record<PropertyKey, any>) => Record<PropertyKey, any>;
|
||||
// /**
|
||||
// * Export star. Sets properties of "fromObject" to "toObject" as getters that return the value from "fromObject", like this:
|
||||
// * @example
|
||||
// * const fromObject = { a: 1 };
|
||||
// * Object.keys(fromObject).forEach(key => {
|
||||
// * if (key !== "default" && !Object.hasOwn(toObject, key)) {
|
||||
// * Object.defineProperty(toObject, key, {
|
||||
// * get: () => fromObject[key],
|
||||
// * enumerable: true
|
||||
// * });
|
||||
// * }
|
||||
// * });
|
||||
// * @returns fromObject
|
||||
// */
|
||||
// es: (this: WebpackRequire, fromObject: Record<PropertyKey, any>, toObject: Record<PropertyKey, any>) => Record<PropertyKey, any>;
|
||||
/**
|
||||
* Creates an async module. A module that exports something that is a Promise, or requires an export from an async module.
|
||||
*
|
||||
|
@ -179,6 +179,8 @@ export type WebpackRequire = ((moduleId: PropertyKey) => ModuleExports) & {
|
|||
v: (this: WebpackRequire, exports: ModuleExports, wasmModuleId: any, wasmModuleHash: string, importsObj?: WebAssembly.Imports) => Promise<any>;
|
||||
/** Bundle public path, where chunk files are stored. Used by other methods which load chunks to obtain the full asset url */
|
||||
p: string;
|
||||
/** The runtime id of the current runtime */
|
||||
j: string;
|
||||
/** Document baseURI or WebWorker location.href */
|
||||
b: string;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue