Fix jumping to patched module source for new React Dev Tools (#3418)

This commit is contained in:
Suffocate 2025-05-16 00:16:51 +01:00 committed by GitHub
parent c2e5dcc384
commit 8023b1be95
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 10 additions and 10 deletions

View file

@ -112,7 +112,7 @@ const buildConfigs = ([
...nodeCommonOpts,
entryPoints: ["src/main/index.ts"],
outfile: "dist/patcher.js",
footer: { js: "//# sourceURL=VencordPatcher\n" + sourceMapFooter("patcher") },
footer: { js: "//# sourceURL=file:///VencordPatcher\n" + sourceMapFooter("patcher") },
sourcemap,
plugins: [
// @ts-ignore this is never undefined
@ -131,7 +131,7 @@ const buildConfigs = ([
outfile: "dist/renderer.js",
format: "iife",
target: ["esnext"],
footer: { js: "//# sourceURL=VencordRenderer\n" + sourceMapFooter("renderer") },
footer: { js: "//# sourceURL=file:///VencordRenderer\n" + sourceMapFooter("renderer") },
globalName: "Vencord",
sourcemap,
plugins: [
@ -148,7 +148,7 @@ const buildConfigs = ([
...nodeCommonOpts,
entryPoints: ["src/preload.ts"],
outfile: "dist/preload.js",
footer: { js: "//# sourceURL=VencordPreload\n" + sourceMapFooter("preload") },
footer: { js: "//# sourceURL=file:///VencordPreload\n" + sourceMapFooter("preload") },
sourcemap,
define: {
...defines,
@ -162,7 +162,7 @@ const buildConfigs = ([
...nodeCommonOpts,
entryPoints: ["src/main/index.ts"],
outfile: "dist/vencordDesktopMain.js",
footer: { js: "//# sourceURL=VencordDesktopMain\n" + sourceMapFooter("vencordDesktopMain") },
footer: { js: "//# sourceURL=file:///VencordDesktopMain\n" + sourceMapFooter("vencordDesktopMain") },
sourcemap,
plugins: [
...nodeCommonOpts.plugins,
@ -180,7 +180,7 @@ const buildConfigs = ([
outfile: "dist/vencordDesktopRenderer.js",
format: "iife",
target: ["esnext"],
footer: { js: "//# sourceURL=VencordDesktopRenderer\n" + sourceMapFooter("vencordDesktopRenderer") },
footer: { js: "//# sourceURL=file:///VencordDesktopRenderer\n" + sourceMapFooter("vencordDesktopRenderer") },
globalName: "Vencord",
sourcemap,
plugins: [
@ -197,7 +197,7 @@ const buildConfigs = ([
...nodeCommonOpts,
entryPoints: ["src/preload.ts"],
outfile: "dist/vencordDesktopPreload.js",
footer: { js: "//# sourceURL=VencordPreload\n" + sourceMapFooter("vencordDesktopPreload") },
footer: { js: "//# sourceURL=file:///VencordPreload\n" + sourceMapFooter("vencordDesktopPreload") },
sourcemap,
define: {
...defines,

View file

@ -82,7 +82,7 @@ const buildConfigs = [
{
...commonOptions,
outfile: "dist/browser.js",
footer: { js: "//# sourceURL=VencordWeb" }
footer: { js: "//# sourceURL=file:///VencordWeb" }
},
{
...commonOptions,
@ -91,7 +91,7 @@ const buildConfigs = [
...commonOptions.define,
IS_EXTENSION: "true"
},
footer: { js: "//# sourceURL=VencordWeb" }
footer: { js: "//# sourceURL=file:///VencordWeb" }
},
{
...commonOptions,

View file

@ -581,7 +581,7 @@ function patchFactory(moduleId: PropertyKey, originalFactory: AnyModuleFactory):
}
code = newCode;
patchedSource = `// Webpack Module ${String(moduleId)} - Patched by ${pluginsList.join(", ")}\n${newCode}\n//# sourceURL=WebpackModule${String(moduleId)}`;
patchedSource = `// Webpack Module ${String(moduleId)} - Patched by ${pluginsList.join(", ")}\n${newCode}\n//# sourceURL=file:///WebpackModule${String(moduleId)}`;
patchedFactory = (0, eval)(patchedSource);
if (!patchedBy.has(patch.plugin)) {

View file

@ -751,7 +751,7 @@ export function extract(id: string | number) {
// This module is NOT ACTUALLY USED! This means putting breakpoints will have NO EFFECT!!
0,${mod.toString()}
//# sourceURL=ExtractedWebpackModule${id}
//# sourceURL=file:///ExtractedWebpackModule${id}
`;
const extracted = (0, eval)(code);
return extracted as Function;