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