From 3c8084ec36b82fdf7ea89aaf6558197d9c070ca9 Mon Sep 17 00:00:00 2001 From: Vendicated Date: Wed, 9 Nov 2022 19:26:39 +0100 Subject: [PATCH] Add VSCode debug config --- .vscode/extensions.json | 10 +++++++++- .vscode/launch.json | 37 +++++++++++++++++++++++++++++++++++++ scripts/build/build.mjs | 15 +++++++++------ 3 files changed, 55 insertions(+), 7 deletions(-) create mode 100644 .vscode/launch.json diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 3df8d339..8922d157 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,3 +1,11 @@ { - "recommendations": [ "EditorConfig.EditorConfig" ] + "recommendations": [ + "EditorConfig.EditorConfig", + "pmneo.tsimporter", + "dbaeumer.vscode-eslint", + "formulahendry.auto-rename-tag", + "GregorBiswanger.json2ts", + "eamodio.gitlens", + "kamikillerto.vscode-colorize" + ] } diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 00000000..dce9770e --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,37 @@ +{ + // this allows you to debug Vencord from VSCode. + // How to use: + // You need to run Discord via the command line to pass some flags to it. + // If you want to debug the main (node.js) process (preload.ts, ipcMain/*, patcher.ts), + // add the --inspect flag + // To debug the renderer (99% of Vencord), add the --remote-debugging-port=9223 flag + // + // Now launch the desired configuration in VSCode and start Discord with the flags. + // For example, to debug both process, run Electron: All then launch Discord with + // discord --remote-debugging-port=9223 --inspect + + "version": "0.2.0", + "configurations": [ + { + "name": "Electron: Main", + "type": "node", + "request": "attach", + "port": 9229, + "timeout": 30000 + }, + { + "name": "Electron: Renderer", + "type": "chrome", + "request": "attach", + "port": 9223, + "timeout": 30000, + "webRoot": "${workspaceFolder}/src" + } + ], + "compounds": [ + { + "name": "Electron: All", + "configurations": ["Electron: Main", "Electron: Renderer"] + } + ] +} diff --git a/scripts/build/build.mjs b/scripts/build/build.mjs index 3d432693..70a05cf9 100755 --- a/scripts/build/build.mjs +++ b/scripts/build/build.mjs @@ -44,20 +44,23 @@ const nodeCommonOpts = { define: defines, }; +const sourceMapFooter = s => watch ? "" : `//# sourceMappingURL=vencord://${s}.js.map`; +const sourcemap = watch ? "inline" : "external"; + await Promise.all([ esbuild.build({ ...nodeCommonOpts, entryPoints: ["src/preload.ts"], outfile: "dist/preload.js", - footer: { js: "//# sourceURL=VencordPreload\n//# sourceMappingURL=vencord://preload.js.map" }, - sourcemap: "external", + footer: { js: "//# sourceURL=VencordPreload\n" + sourceMapFooter("preload") }, + sourcemap, }), esbuild.build({ ...nodeCommonOpts, entryPoints: ["src/patcher.ts"], outfile: "dist/patcher.js", - footer: { js: "//# sourceURL=VencordPatcher\n//# sourceMappingURL=vencord://patcher.js.map" }, - sourcemap: "external", + footer: { js: "//# sourceURL=VencordPatcher\n" + sourceMapFooter("patcher") }, + sourcemap, }), esbuild.build({ ...commonOpts, @@ -65,9 +68,9 @@ await Promise.all([ outfile: "dist/renderer.js", format: "iife", target: ["esnext"], - footer: { js: "//# sourceURL=VencordRenderer\n//# sourceMappingURL=vencord://renderer.js.map" }, + footer: { js: "//# sourceURL=VencordRenderer\n" + sourceMapFooter("renderer") }, globalName: "Vencord", - sourcemap: "external", + sourcemap, plugins: [ globPlugins, ...commonOpts.plugins