this repo has no description

Merge pull request #214 from uwx/feature/group-prefix-wp-modules

Fix very laggy Sources tab in DevTools when using "Patch all" in Spacepack

authored by

Cynthia Foxwell and committed by
GitHub
cb34ba0a b39af378

+7 -6
+3 -3
packages/core-extensions/src/moonbase/webpackModules/crashScreen.tsx
··· 6 6 import { ConfigExtension, DetectedExtension } from "@moonlight-mod/types"; 7 7 import DiscoveryClasses from "@moonlight-mod/wp/discord/modules/discovery/web/Discovery.css"; 8 8 9 - const MODULE_REGEX = /Webpack-Module-(\d+)/g; 9 + const MODULE_REGEX = /Webpack-Module\/(\d+)\/(\d+)/g; 10 10 11 11 const logger = moonlight.getLogger("moonbase/crashScreen"); 12 12 ··· 139 139 const causes = React.useMemo(() => { 140 140 const causes = new Set<string>(); 141 141 if (state.error.stack) { 142 - for (const [, id] of state.error.stack.matchAll(MODULE_REGEX)) 142 + for (const [, , id] of state.error.stack.matchAll(MODULE_REGEX)) 143 143 for (const ext of moonlight.patched.get(id) ?? []) causes.add(ext); 144 144 } 145 - for (const [, id] of state.info.componentStack.matchAll(MODULE_REGEX)) 145 + for (const [, , id] of state.info.componentStack.matchAll(MODULE_REGEX)) 146 146 for (const ext of moonlight.patched.get(id) ?? []) causes.add(ext); 147 147 return [...causes]; 148 148 }, []);
+1 -1
packages/core-extensions/src/spacepack/webpackModules/spacepack.ts
··· 37 37 "module", 38 38 "exports", 39 39 "require", 40 - `(${funcStr}).apply(this, arguments)\n` + `//# sourceURL=Webpack-Module-${module}` 40 + `(${funcStr}).apply(this, arguments)\n` + `//# sourceURL=Webpack-Module/${module.slice(0, 3)}/${module}` 41 41 ) as WebpackModuleFunc; 42 42 }, 43 43
+3 -2
packages/core/src/patch.ts
··· 79 79 const wrapped = 80 80 `(${replaced}).apply(this, arguments)\n` + 81 81 `// Patched by moonlight: ${patchedStr}\n` + 82 - `//# sourceURL=Webpack-Module-${id}`; 82 + `//# sourceURL=Webpack-Module/${id.slice(0, 3)}/${id}`; 83 83 84 84 try { 85 85 const func = new Function("module", "exports", "require", wrapped) as WebpackModuleFunc; ··· 205 205 206 206 if (moonlightNode.config.patchAll === true) { 207 207 if ((typeof id !== "string" || !id.includes("_")) && !entry[id].__moonlight) { 208 - const wrapped = `(${moduleCache[id]}).apply(this, arguments)\n` + `//# sourceURL=Webpack-Module-${id}`; 208 + const wrapped = 209 + `(${moduleCache[id]}).apply(this, arguments)\n` + `//# sourceURL=Webpack-Module/${id.slice(0, 3)}/${id}`; 209 210 entry[id] = new Function("module", "exports", "require", wrapped) as WebpackModuleFunc; 210 211 entry[id].__moonlight = true; 211 212 }