diff --git a/.review/pr-8274 b/.review/pr-8274 new file mode 160000 index 0000000000..e46929b8d8 --- /dev/null +++ b/.review/pr-8274 @@ -0,0 +1 @@ +Subproject commit e46929b8d8add0cd3c412d69f8ac882c405a4ba9 diff --git a/tmp/pr-8287-Roo-Code b/tmp/pr-8287-Roo-Code new file mode 160000 index 0000000000..88a473b017 --- /dev/null +++ b/tmp/pr-8287-Roo-Code @@ -0,0 +1 @@ +Subproject commit 88a473b017af37091c85ce3056e444e856f80d6e diff --git a/webview-ui/src/vite-plugins/sourcemapPlugin.ts b/webview-ui/src/vite-plugins/sourcemapPlugin.ts index 1449c888f2..e1d379ef01 100644 --- a/webview-ui/src/vite-plugins/sourcemapPlugin.ts +++ b/webview-ui/src/vite-plugins/sourcemapPlugin.ts @@ -60,14 +60,29 @@ export function sourcemapPlugin(): Plugin { // Read the JS file let jsContent = fs.readFileSync(jsPath, "utf8") - // Check if the source map is already referenced - if (!jsContent.includes("//# sourceMappingURL=")) { + // Check if the source map is already referenced or has incorrect reference + const sourceMappingURLRegex = /\/\/# sourceMappingURL=([^\s\n]+)/ + const match = jsContent.match(sourceMappingURLRegex) + + if (match) { + // Check if the existing reference is incorrect (e.g., index.sourcemap instead of index.js.map) + const currentMapRef = match[1] + const expectedMapRef = `${jsFile}.map` + + if (currentMapRef !== expectedMapRef) { + console.log( + `Fixing source map reference in ${jsFile}: ${currentMapRef} -> ${expectedMapRef}`, + ) + jsContent = jsContent.replace( + sourceMappingURLRegex, + `//# sourceMappingURL=${expectedMapRef}`, + ) + fs.writeFileSync(jsPath, jsContent) + } + } else { console.log(`Adding source map reference to ${jsFile}`) - - // Add source map reference + // Add source map reference with explicit .map extension jsContent += `\n//# sourceMappingURL=${jsFile}.map\n` - - // Write the updated JS file fs.writeFileSync(jsPath, jsContent) }