(extensions, moduleName, containingDirectory, loader, state)
| 43193 | } |
| 43194 | } |
| 43195 | function tryLoadModuleUsingRootDirs(extensions, moduleName, containingDirectory, loader, state) { |
| 43196 | if (!state.compilerOptions.rootDirs) { |
| 43197 | return undefined; |
| 43198 | } |
| 43199 | if (state.traceEnabled) { |
| 43200 | trace(state.host, ts.Diagnostics.rootDirs_option_is_set_using_it_to_resolve_relative_module_name_0, moduleName); |
| 43201 | } |
| 43202 | var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); |
| 43203 | var matchedRootDir; |
| 43204 | var matchedNormalizedPrefix; |
| 43205 | for (var _i = 0, _a = state.compilerOptions.rootDirs; _i < _a.length; _i++) { |
| 43206 | var rootDir = _a[_i]; |
| 43207 | // rootDirs are expected to be absolute |
| 43208 | // in case of tsconfig.json this will happen automatically - compiler will expand relative names |
| 43209 | // using location of tsconfig.json as base location |
| 43210 | var normalizedRoot = ts.normalizePath(rootDir); |
| 43211 | if (!ts.endsWith(normalizedRoot, ts.directorySeparator)) { |
| 43212 | normalizedRoot += ts.directorySeparator; |
| 43213 | } |
| 43214 | var isLongestMatchingPrefix = ts.startsWith(candidate, normalizedRoot) && |
| 43215 | (matchedNormalizedPrefix === undefined || matchedNormalizedPrefix.length < normalizedRoot.length); |
| 43216 | if (state.traceEnabled) { |
| 43217 | trace(state.host, ts.Diagnostics.Checking_if_0_is_the_longest_matching_prefix_for_1_2, normalizedRoot, candidate, isLongestMatchingPrefix); |
| 43218 | } |
| 43219 | if (isLongestMatchingPrefix) { |
| 43220 | matchedNormalizedPrefix = normalizedRoot; |
| 43221 | matchedRootDir = rootDir; |
| 43222 | } |
| 43223 | } |
| 43224 | if (matchedNormalizedPrefix) { |
| 43225 | if (state.traceEnabled) { |
| 43226 | trace(state.host, ts.Diagnostics.Longest_matching_prefix_for_0_is_1, candidate, matchedNormalizedPrefix); |
| 43227 | } |
| 43228 | var suffix = candidate.substr(matchedNormalizedPrefix.length); |
| 43229 | // first - try to load from a initial location |
| 43230 | if (state.traceEnabled) { |
| 43231 | trace(state.host, ts.Diagnostics.Loading_0_from_the_root_dir_1_candidate_location_2, suffix, matchedNormalizedPrefix, candidate); |
| 43232 | } |
| 43233 | var resolvedFileName = loader(extensions, candidate, !ts.directoryProbablyExists(containingDirectory, state.host), state); |
| 43234 | if (resolvedFileName) { |
| 43235 | return resolvedFileName; |
| 43236 | } |
| 43237 | if (state.traceEnabled) { |
| 43238 | trace(state.host, ts.Diagnostics.Trying_other_entries_in_rootDirs); |
| 43239 | } |
| 43240 | // then try to resolve using remaining entries in rootDirs |
| 43241 | for (var _b = 0, _c = state.compilerOptions.rootDirs; _b < _c.length; _b++) { |
| 43242 | var rootDir = _c[_b]; |
| 43243 | if (rootDir === matchedRootDir) { |
| 43244 | // skip the initially matched entry |
| 43245 | continue; |
| 43246 | } |
| 43247 | var candidate_1 = ts.combinePaths(ts.normalizePath(rootDir), suffix); |
| 43248 | if (state.traceEnabled) { |
| 43249 | trace(state.host, ts.Diagnostics.Loading_0_from_the_root_dir_1_candidate_location_2, suffix, rootDir, candidate_1); |
| 43250 | } |
| 43251 | var baseDirectory = ts.getDirectoryPath(candidate_1); |
| 43252 | var resolvedFileName_1 = loader(extensions, candidate_1, !ts.directoryProbablyExists(baseDirectory, state.host), state); |
no test coverage detected
searching dependent graphs…