@@ -704,27 +704,16 @@ exports.main = function main(argv, options, callback) {
704704 if ( args . binaryFile . length ) {
705705 let sourceMap = JSON . parse ( wasm . sourceMap ) ;
706706 sourceMap . sourceRoot = exports . sourceMapRoot ;
707- sourceMap . sources . forEach ( ( name , index ) => {
708- let text = null ;
709- if ( name . startsWith ( exports . libraryPrefix ) ) {
710- let stdName = name . substring ( exports . libraryPrefix . length ) . replace ( / \. t s $ / , "" ) ;
711- if ( exports . libraryFiles . hasOwnProperty ( stdName ) ) {
712- text = exports . libraryFiles [ stdName ] ;
713- } else {
714- for ( let i = 0 , k = customLibDirs . length ; i < k ; ++ i ) {
715- text = readFile ( name . substring ( exports . libraryPrefix . length ) , customLibDirs [ i ] ) ;
716- if ( text !== null ) break ;
717- }
718- }
719- } else {
720- text = readFile ( name , baseDir ) ;
721- }
722- if ( text === null ) {
723- return callback ( Error ( "Source file '" + name + "' not found." ) ) ;
707+ console . log ( sourceMap . sources )
708+ for ( const index in sourceMap . sources ) {
709+ let internalPath = sourceMap . sources [ index ] . replace ( / \. t s $ / , "" ) ;
710+ let source = program . sources . find ( source => source . internalPath === internalPath ) ;
711+ if ( ! source ) {
712+ return callback ( Error ( "Source file '" + internalPath + ".ts' not found." ) ) ;
724713 }
725714 if ( ! sourceMap . sourceContents ) sourceMap . sourceContents = [ ] ;
726- sourceMap . sourceContents [ index ] = text ;
727- } ) ;
715+ sourceMap . sourceContents [ index ] = source . text ;
716+ }
728717 writeFile ( path . join (
729718 path . dirname ( args . binaryFile ) ,
730719 path . basename ( sourceMapURL )
0 commit comments