@@ -390,19 +390,24 @@ namespace ts {
390390 const firstLineColumnOffset = writer . getColumn ( ) ;
391391 // First, decode the old component sourcemap
392392 const originalMap = parsed ;
393+
394+ const sourcesDirectoryPath = compilerOptions . sourceRoot ? host . getCommonSourceDirectory ( ) : sourceMapDir ;
395+ const resolvedPathCache = createMap < string > ( ) ;
393396 sourcemaps . calculateDecodedMappings ( originalMap , ( raw ) : void => {
394397 // Apply offsets to each position and fixup source entries
395398 const rawPath = originalMap . sources [ raw . sourceIndex ] ;
396399 const relativePath = originalMap . sourceRoot ? combinePaths ( originalMap . sourceRoot , rawPath ) : rawPath ;
397400 const combinedPath = combinePaths ( getDirectoryPath ( node . sourceMapPath ! ) , relativePath ) ;
398- const sourcesDirectoryPath = compilerOptions . sourceRoot ? host . getCommonSourceDirectory ( ) : sourceMapDir ;
399- const resolvedPath = getRelativePathToDirectoryOrUrl (
400- sourcesDirectoryPath ,
401- combinedPath ,
402- host . getCurrentDirectory ( ) ,
403- host . getCanonicalFileName ,
404- /*isAbsolutePathAnUrl*/ true
405- ) ;
401+ if ( ! resolvedPathCache . has ( combinedPath ) ) {
402+ resolvedPathCache . set ( combinedPath , getRelativePathToDirectoryOrUrl (
403+ sourcesDirectoryPath ,
404+ combinedPath ,
405+ host . getCurrentDirectory ( ) ,
406+ host . getCanonicalFileName ,
407+ /*isAbsolutePathAnUrl*/ true
408+ ) ) ;
409+ }
410+ const resolvedPath = resolvedPathCache . get ( combinedPath ) ! ;
406411 const absolutePath = getNormalizedAbsolutePath ( resolvedPath , sourcesDirectoryPath ) ;
407412 // tslint:disable-next-line:no-null-keyword
408413 setupSourceEntry ( absolutePath , originalMap . sourcesContent ? originalMap . sourcesContent [ raw . sourceIndex ] : null ) ; // TODO: Lookup content for inlining?
0 commit comments