mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-15 03:23:08 -06:00
Merge pull request #25048 from RyanCavanaugh/cachePathsInSourceMaps
Do fewer calls to getRelativePathToDirectoryOrUrl when writing sourcemaps
This commit is contained in:
commit
e060871e85
@ -390,19 +390,24 @@ namespace ts {
|
||||
const firstLineColumnOffset = writer.getColumn();
|
||||
// First, decode the old component sourcemap
|
||||
const originalMap = parsed;
|
||||
|
||||
const sourcesDirectoryPath = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir;
|
||||
const resolvedPathCache = createMap<string>();
|
||||
sourcemaps.calculateDecodedMappings(originalMap, (raw): void => {
|
||||
// Apply offsets to each position and fixup source entries
|
||||
const rawPath = originalMap.sources[raw.sourceIndex];
|
||||
const relativePath = originalMap.sourceRoot ? combinePaths(originalMap.sourceRoot, rawPath) : rawPath;
|
||||
const combinedPath = combinePaths(getDirectoryPath(node.sourceMapPath!), relativePath);
|
||||
const sourcesDirectoryPath = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir;
|
||||
const resolvedPath = getRelativePathToDirectoryOrUrl(
|
||||
sourcesDirectoryPath,
|
||||
combinedPath,
|
||||
host.getCurrentDirectory(),
|
||||
host.getCanonicalFileName,
|
||||
/*isAbsolutePathAnUrl*/ true
|
||||
);
|
||||
if (!resolvedPathCache.has(combinedPath)) {
|
||||
resolvedPathCache.set(combinedPath, getRelativePathToDirectoryOrUrl(
|
||||
sourcesDirectoryPath,
|
||||
combinedPath,
|
||||
host.getCurrentDirectory(),
|
||||
host.getCanonicalFileName,
|
||||
/*isAbsolutePathAnUrl*/ true
|
||||
));
|
||||
}
|
||||
const resolvedPath = resolvedPathCache.get(combinedPath)!;
|
||||
const absolutePath = getNormalizedAbsolutePath(resolvedPath, sourcesDirectoryPath);
|
||||
// tslint:disable-next-line:no-null-keyword
|
||||
setupSourceEntry(absolutePath, originalMap.sourcesContent ? originalMap.sourcesContent[raw.sourceIndex] : null); // TODO: Lookup content for inlining?
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user