File tree Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change 1
1
import { formatDiagnostic , getCompilerOptions , transpile } from '../test-transpile' ;
2
+ import { basename } from 'path' ;
2
3
3
4
4
5
export const jestPreprocessor = {
@@ -20,11 +21,17 @@ export const jestPreprocessor = {
20
21
const msg = results . diagnostics . map ( formatDiagnostic ) . join ( '\n\n' ) ;
21
22
throw new Error ( msg ) ;
22
23
}
24
+ const mapObject = JSON . parse ( results . map ) ;
25
+ const base = basename ( filePath ) ;
26
+ mapObject . file = filePath ;
27
+ mapObject . sources = [ filePath ] ;
28
+ delete mapObject . sourceRoot ;
23
29
24
- return {
25
- code : results . code ,
26
- map : results . map
27
- } ;
30
+ const mapBase64 = Buffer . from ( JSON . stringify ( mapObject ) , 'utf8' ) . toString ( 'base64' ) ;
31
+ const sourceMapInlined = `data:application/json;charset=utf-8;base64,${ mapBase64 } ` ;
32
+ const sourceMapLength = `${ base } .map` . length ;
33
+
34
+ return results . code . slice ( 0 , - sourceMapLength ) + sourceMapInlined ;
28
35
}
29
36
30
37
return sourceText ;
You can’t perform that action at this time.
0 commit comments