diff --git a/src/compiler/path.ts b/src/compiler/path.ts index 27b5330b2cedc..d09108d34c7f3 100644 --- a/src/compiler/path.ts +++ b/src/compiler/path.ts @@ -552,6 +552,19 @@ namespace ts { export function normalizePath(path: string): string { path = normalizeSlashes(path); + // Most paths don't require normalization + if (!relativePathSegmentRegExp.test(path)) { + return path; + } + // Some paths only require cleanup of `/./` or leading `./` + const simplified = path.replace(/\/\.\//g, "/").replace(/^\.\//, ""); + if (simplified !== path) { + path = simplified; + if (!relativePathSegmentRegExp.test(path)) { + return path; + } + } + // Other paths require full normalization const normalized = getPathFromPathComponents(reducePathComponents(getPathComponents(path))); return normalized && hasTrailingDirectorySeparator(path) ? ensureTrailingDirectorySeparator(normalized) : normalized; }