()
| 633 | } |
| 634 | |
| 635 | func (r *resolutionState) loadModuleFromImports() *resolved { |
| 636 | if r.name == "#" || (strings.HasPrefix(r.name, "#/") && (r.features&NodeResolutionFeaturesImportsPatternRoot) == 0) { |
| 637 | if r.tracer != nil { |
| 638 | r.tracer.write(diagnostics.Invalid_import_specifier_0_has_no_possible_resolutions, r.name) |
| 639 | } |
| 640 | return continueSearching() |
| 641 | } |
| 642 | directoryPath := tspath.GetNormalizedAbsolutePath(r.containingDirectory, r.resolver.host.GetCurrentDirectory()) |
| 643 | scope := r.getPackageScopeForPath(directoryPath) |
| 644 | if !scope.Exists() { |
| 645 | if r.tracer != nil { |
| 646 | r.tracer.write(diagnostics.Directory_0_has_no_containing_package_json_scope_Imports_will_not_resolve, directoryPath) |
| 647 | } |
| 648 | return continueSearching() |
| 649 | } |
| 650 | if scope.Contents.Imports.Type != packagejson.JSONValueTypeObject { |
| 651 | // !!! Old compiler only checks for undefined, but then assumes `imports` is an object if present. |
| 652 | // Maybe should have a new diagnostic for imports of an invalid type. Also, array should be handled? |
| 653 | if r.tracer != nil { |
| 654 | r.tracer.write(diagnostics.X_package_json_scope_0_has_no_imports_defined, scope.PackageDirectory) |
| 655 | } |
| 656 | return continueSearching() |
| 657 | } |
| 658 | |
| 659 | if result := r.loadModuleFromExportsOrImports(r.extensions, r.name, scope.Contents.Imports.AsObject(), scope /*isImports*/, true); !result.shouldContinueSearching() { |
| 660 | return result |
| 661 | } |
| 662 | |
| 663 | if r.tracer != nil { |
| 664 | r.tracer.write(diagnostics.Import_specifier_0_does_not_exist_in_package_json_scope_at_path_1, r.name, scope.PackageDirectory) |
| 665 | } |
| 666 | return continueSearching() |
| 667 | } |
| 668 | |
| 669 | func (r *resolutionState) loadModuleFromExports(packageInfo *packagejson.InfoCacheEntry, ext extensions, subpath string) *resolved { |
| 670 | // !!! This is ported exactly, but the falsy check seems wrong |
no test coverage detected