Enable source maps and improve debugging support

This commit enables source maps in napcat-shell's Vite config for better debugging, adds source map path overrides to VSCode settings, and updates nodeTest.ps1 to launch with the Node.js inspector. The autoIncludeTSPlugin transform now returns a source map for improved breakpoint support in VSCode. Also adds a sources.txt file listing project and dependency sources.
This commit is contained in:
手瓜一十雪 2025-11-14 21:21:49 +08:00
parent b99c0ca437
commit 66d02eeb6a
4 changed files with 19 additions and 6 deletions

View File

@ -1,2 +1,9 @@
{ {
"debug.node.sourceMapPathOverrides": {
"../../napcat-onebot/*": "${workspaceFolder}/packages/napcat-onebot/*",
"../../napcat-core/*": "${workspaceFolder}/packages/napcat-core/*",
"../../napcat-common/*": "${workspaceFolder}/packages/napcat-common/*",
"../../napcat-webui-backend/*": "${workspaceFolder}/packages/napcat-webui-backend/*",
"../../napcat-pty/*": "${workspaceFolder}/packages/napcat-pty/*"
}
} }

View File

@ -5,4 +5,4 @@ $uninstall = $uninstall.Trim('"')
$qqPath = Split-Path $uninstall -Parent $qqPath = Split-Path $uninstall -Parent
Write-Host "QQPath: $qqPath" Write-Host "QQPath: $qqPath"
node.exe "./loadNapCat.cjs" "$qqPath" node.exe --inspect "./loadNapCat.cjs" "$qqPath"

View File

@ -48,7 +48,7 @@ const ShellBaseConfig = () =>
}, },
}, },
build: { build: {
sourcemap: false, sourcemap: true,
target: 'esnext', target: 'esnext',
minify: false, minify: false,
lib: { lib: {
@ -61,7 +61,7 @@ const ShellBaseConfig = () =>
fileName: (_, entryName) => `${entryName}.mjs`, fileName: (_, entryName) => `${entryName}.mjs`,
}, },
rollupOptions: { rollupOptions: {
external: [...nodeModules, ...external], external: [...nodeModules, ...external]
}, },
}, },
}); });

View File

@ -35,7 +35,6 @@ export function autoIncludeTSPlugin(options) {
transform(code, id) { transform(code, id) {
for (const [entry, tsFiles] of Object.entries(tsFilesMap)) { for (const [entry, tsFiles] of Object.entries(tsFilesMap)) {
// 检查id是否匹配entry支持完整路径或相对路径
const isMatch = id.endsWith(entry) || id.includes(entry); const isMatch = id.endsWith(entry) || id.includes(entry);
if (isMatch && tsFiles.length > 0) { if (isMatch && tsFiles.length > 0) {
const imports = tsFiles.map(filePath => { const imports = tsFiles.map(filePath => {
@ -43,11 +42,18 @@ export function autoIncludeTSPlugin(options) {
return `import './${relativePath}';`; return `import './${relativePath}';`;
}).join('\n'); }).join('\n');
return imports + '\n' + code; const transformedCode = imports + '\n' + code;
return {
code: transformedCode,
map: { mappings: '' } // 空映射即可VSCode 可以在 TS 上断点
};
} }
} }
return code;
return null;
}, },
}; };
} }