From 9c24c8eeda7e1b5fe29e840b2590804893d0d416 Mon Sep 17 00:00:00 2001 From: Navya Singh Date: Fri, 2 Oct 2026 15:32:42 -0700 Subject: [PATCH] fix: resolve namespaced webpack sources in VS ClientApp Recognize webpack 5 namespace URLs when applying Visual Studio's ASP.NET ClientApp source-map fallback, and cover Vue CLI 5 source paths with a regression test. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../browser/browserPathResolver.test.ts | 29 +++++++++++++++---- src/targets/browser/browserPathResolver.ts | 2 +- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/src/targets/browser/browserPathResolver.test.ts b/src/targets/browser/browserPathResolver.test.ts index 1d3b93a7c..eb58ab175 100644 --- a/src/targets/browser/browserPathResolver.test.ts +++ b/src/targets/browser/browserPathResolver.test.ts @@ -148,8 +148,10 @@ describe('BrowserPathResolver', () => { exists(path: string): Promise { switch (path) { case 'c:\\Users\\user\\Source\\Repos\\Angular Project\\ClientApp\\src\\app\\app.component.html': + case 'c:\\Users\\user\\Source\\Repos\\Angular Project\\ClientApp\\src\\components\\Component.vue': return Promise.resolve(true); case 'c:\\Users\\user\\Source\\Repos\\Angular Project\\wwwroot\\src\\app\\app.component.html': + case 'c:\\Users\\user\\Source\\Repos\\Angular Project\\wwwroot\\src\\components\\Component.vue': return Promise.resolve(false); default: throw Error(`Unknown path ${path}`); @@ -231,10 +233,26 @@ describe('BrowserPathResolver', () => { }); [ - ['visualstudio', 'ClientApp'], - ['vscode', 'wwwroot'], - ].forEach(([client, folder]) => { - it(`returns ${folder} for ${client} if the webroot path doesn't exist and the modified path does`, async () => { + [ + 'visualstudio', + 'webpack:///src/app/app.component.html', + 'ClientApp', + 'src\\app\\app.component.html', + ], + [ + 'visualstudio', + 'webpack://vue-app/src/components/Component.vue', + 'ClientApp', + 'src\\components\\Component.vue', + ], + [ + 'vscode', + 'webpack:///src/app/app.component.html', + 'wwwroot', + 'src\\app\\app.component.html', + ], + ].forEach(([client, url, folder, relativePath]) => { + it(`returns ${folder} for ${client} and ${url} if the webroot path doesn't exist and the modified path does`, async () => { const webRoot = 'c:\\Users\\user\\Source\\Repos\\Angular Project\\wwwroot'; const resolver = new BrowserSourcePathResolver( @@ -254,14 +272,13 @@ describe('BrowserPathResolver', () => { await Logger.test(), ); - const url = 'webpack:///src/app/app.component.html'; const absolutePath = await resolver.urlToAbsolutePath({ url, map: upcastPartial({ metadata: { sourceMapUrl: '', compiledPath: 'x' } }), }); expect(absolutePath).to.equal( - `c:\\Users\\user\\Source\\Repos\\Angular Project\\${folder}\\src\\app\\app.component.html`, + `c:\\Users\\user\\Source\\Repos\\Angular Project\\${folder}\\${relativePath}`, ); }); }); diff --git a/src/targets/browser/browserPathResolver.ts b/src/targets/browser/browserPathResolver.ts index f64a735a9..c3f1835f2 100644 --- a/src/targets/browser/browserPathResolver.ts +++ b/src/targets/browser/browserPathResolver.ts @@ -198,7 +198,7 @@ export class BrowserSourcePathResolver extends SourcePathResolverBase ); if ( this.options.clientID === 'visualstudio' - && fullSourceEntry.startsWith('webpack:///') + && fullSourceEntry.startsWith('webpack://') && !(await this.fsUtils.exists(mappedFullSourceEntry)) && (await this.fsUtils.exists(clientAppPath)) ) {