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 11import { formatDiagnostic , getCompilerOptions , transpile } from '../test-transpile' ;
2+ import { basename } from 'path' ;
23
34
45export const jestPreprocessor = {
@@ -20,11 +21,17 @@ export const jestPreprocessor = {
2021 const msg = results . diagnostics . map ( formatDiagnostic ) . join ( '\n\n' ) ;
2122 throw new Error ( msg ) ;
2223 }
24+ const mapObject = JSON . parse ( results . map ) ;
25+ const base = basename ( filePath ) ;
26+ mapObject . file = filePath ;
27+ mapObject . sources = [ filePath ] ;
28+ delete mapObject . sourceRoot ;
2329
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 ;
2835 }
2936
3037 return sourceText ;
You can’t perform that action at this time.
0 commit comments