Commit 723cd63 authored Sep 20, 2021 Verified
1 parent 06eb57e commit 723cd63 Copy full SHA for 723cd63
File tree 2 files changed +21
-14
lines changed
2 files changed +21
-14
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,8 @@ import {
12
12
cleanUrl ,
13
13
createDebugger ,
14
14
ensureWatchedFile ,
15
- generateCodeFrame
15
+ generateCodeFrame ,
16
+ toUpperCaseDriveLetter
16
17
} from '../utils'
17
18
import { RawSourceMap } from '@ampproject/remapping/dist/types/types'
18
19
import { SourceMap } from 'rollup'
@@ -126,23 +127,25 @@ export async function transformWithEsbuild(
126
127
127
128
try {
128
129
const result = await transform ( code , resolvedOptions )
130
+ let map : SourceMap
129
131
if ( inMap && resolvedOptions . sourcemap ) {
130
132
const nextMap = JSON . parse ( result . map )
131
133
nextMap . sourcesContent = [ ]
132
- return {
133
- ...result ,
134
- map : combineSourcemaps ( filename , [
135
- nextMap as RawSourceMap ,
136
- inMap as RawSourceMap
137
- ] ) as SourceMap
138
- }
134
+ map = combineSourcemaps ( filename , [
135
+ nextMap as RawSourceMap ,
136
+ inMap as RawSourceMap
137
+ ] ) as SourceMap
139
138
} else {
140
- return {
141
- ...result ,
142
- map : resolvedOptions . sourcemap
143
- ? JSON . parse ( result . map )
144
- : { mappings : '' }
145
- }
139
+ map = resolvedOptions . sourcemap
140
+ ? JSON . parse ( result . map )
141
+ : { mappings : '' }
142
+ }
143
+ if ( Array . isArray ( map . sources ) ) {
144
+ map . sources = map . sources . map ( ( it ) => toUpperCaseDriveLetter ( it ) )
145
+ }
146
+ return {
147
+ ...result ,
148
+ map
146
149
}
147
150
} catch ( e ) {
148
151
debug ( `esbuild error with options used: ` , resolvedOptions )
Original file line number Diff line number Diff line change @@ -561,5 +561,9 @@ export function arraify<T>(target: T | T[]): T[] {
561
561
return Array . isArray ( target ) ? target : [ target ]
562
562
}
563
563
564
+ export function toUpperCaseDriveLetter ( pathName : string ) : string {
565
+ return pathName . replace ( / ^ \w : / , letter => letter . toUpperCase ( ) )
566
+ }
567
+
564
568
export const multilineCommentsRE = / \/ \* ( .| [ \r \n ] ) * ?\* \/ / gm
565
569
export const singlelineCommentsRE = / \/ \/ .* / g
You can’t perform that action at this time.
0 commit comments