(extensions, candidate, onlyRecordFailures, state, considerPackageJson)
| 43434 | return real; |
| 43435 | } |
| 43436 | function nodeLoadModuleByRelativeName(extensions, candidate, onlyRecordFailures, state, considerPackageJson) { |
| 43437 | if (state.traceEnabled) { |
| 43438 | trace(state.host, ts.Diagnostics.Loading_module_as_file_Slash_folder_candidate_module_location_0_target_file_type_1, candidate, Extensions[extensions]); |
| 43439 | } |
| 43440 | if (!ts.hasTrailingDirectorySeparator(candidate)) { |
| 43441 | if (!onlyRecordFailures) { |
| 43442 | var parentOfCandidate = ts.getDirectoryPath(candidate); |
| 43443 | if (!ts.directoryProbablyExists(parentOfCandidate, state.host)) { |
| 43444 | if (state.traceEnabled) { |
| 43445 | trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, parentOfCandidate); |
| 43446 | } |
| 43447 | onlyRecordFailures = true; |
| 43448 | } |
| 43449 | } |
| 43450 | var resolvedFromFile = loadModuleFromFile(extensions, candidate, onlyRecordFailures, state); |
| 43451 | if (resolvedFromFile) { |
| 43452 | var packageDirectory = considerPackageJson ? parseNodeModuleFromPath(resolvedFromFile.path) : undefined; |
| 43453 | var packageInfo = packageDirectory ? getPackageJsonInfo(packageDirectory, /*onlyRecordFailures*/ false, state) : undefined; |
| 43454 | return withPackageId(packageInfo, resolvedFromFile); |
| 43455 | } |
| 43456 | } |
| 43457 | if (!onlyRecordFailures) { |
| 43458 | var candidateExists = ts.directoryProbablyExists(candidate, state.host); |
| 43459 | if (!candidateExists) { |
| 43460 | if (state.traceEnabled) { |
| 43461 | trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, candidate); |
| 43462 | } |
| 43463 | onlyRecordFailures = true; |
| 43464 | } |
| 43465 | } |
| 43466 | // esm mode relative imports shouldn't do any directory lookups (either inside `package.json` |
| 43467 | // files or implicit `index.js`es). This is a notable depature from cjs norms, where `./foo/pkg` |
| 43468 | // could have been redirected by `./foo/pkg/package.json` to an arbitrary location! |
| 43469 | if (!(state.features & NodeResolutionFeatures.EsmMode)) { |
| 43470 | return loadNodeModuleFromDirectory(extensions, candidate, onlyRecordFailures, state, considerPackageJson); |
| 43471 | } |
| 43472 | return undefined; |
| 43473 | } |
| 43474 | /*@internal*/ |
| 43475 | ts.nodeModulesPathPart = "/node_modules/"; |
| 43476 | /*@internal*/ |
no test coverage detected
searching dependent graphs…