File tree Expand file tree Collapse file tree 1 file changed +28
-3
lines changed
packages/bundler-plugin-core/src Expand file tree Collapse file tree 1 file changed +28
-3
lines changed Original file line number Diff line number Diff line change @@ -298,10 +298,35 @@ async function determineSourceMapPathFromBundle(
298298 const sourceMappingUrlMatch = bundleSource . match ( / ^ \s * \/ \/ # s o u r c e M a p p i n g U R L = ( .* ) $ / m) ;
299299 if ( sourceMappingUrlMatch ) {
300300 const sourceMappingUrl = path . normalize ( sourceMappingUrlMatch [ 1 ] as string ) ;
301- if ( path . isAbsolute ( sourceMappingUrl ) ) {
302- return sourceMappingUrl ;
301+
302+ let isUrl ;
303+ let isSupportedUrl ;
304+ try {
305+ const url = new URL ( sourceMappingUrl ) ;
306+ isUrl = true ;
307+ isSupportedUrl = url . protocol === "file:" ;
308+ } catch {
309+ isUrl = false ;
310+ isSupportedUrl = false ;
311+ }
312+
313+ let absoluteSourceMapPath ;
314+ if ( isSupportedUrl ) {
315+ absoluteSourceMapPath = sourceMappingUrl ;
316+ } else if ( isUrl ) {
317+ return ;
318+ } else if ( path . isAbsolute ( sourceMappingUrl ) ) {
319+ absoluteSourceMapPath = sourceMappingUrl ;
303320 } else {
304- return path . join ( path . dirname ( bundlePath ) , sourceMappingUrl ) ;
321+ absoluteSourceMapPath = path . join ( path . dirname ( bundlePath ) , sourceMappingUrl ) ;
322+ }
323+
324+ try {
325+ // Check if the file actually exists
326+ await util . promisify ( fs . access ) ( absoluteSourceMapPath ) ;
327+ return absoluteSourceMapPath ;
328+ } catch ( e ) {
329+ // noop
305330 }
306331 }
307332
You can’t perform that action at this time.
0 commit comments