(name string)
| 642 | } |
| 643 | |
| 644 | func (p *fileLoader) pathForLibFile(name string) *LibFile { |
| 645 | if cached, ok := p.pathForLibFileCache.Load(name); ok { |
| 646 | return cached |
| 647 | } |
| 648 | |
| 649 | path := tspath.CombinePaths(p.defaultLibraryPath, name) |
| 650 | replaced := false |
| 651 | if p.opts.Config.CompilerOptions().LibReplacement.IsTrue() && name != "lib.d.ts" { |
| 652 | libraryName := getLibraryNameFromLibFileName(name) |
| 653 | resolveFrom := getInferredLibraryNameResolveFrom(p.opts.Config.CompilerOptions(), p.opts.Host.GetCurrentDirectory(), name) |
| 654 | resolution, trace := p.resolveLibrary(libraryName, resolveFrom) |
| 655 | if resolution.IsResolved() { |
| 656 | path = resolution.ResolvedFileName |
| 657 | replaced = true |
| 658 | } |
| 659 | p.pathForLibFileResolutions.LoadOrStore(p.toPath(resolveFrom), &libResolution{ |
| 660 | libraryName: libraryName, |
| 661 | resolution: resolution, |
| 662 | trace: trace, |
| 663 | }) |
| 664 | } |
| 665 | |
| 666 | libPath, _ := p.pathForLibFileCache.LoadOrStore(name, &LibFile{name, path, replaced}) |
| 667 | return libPath |
| 668 | } |
| 669 | |
| 670 | func (p *fileLoader) resolveLibrary(libraryName, resolveFrom string) (*module.ResolvedModule, []module.DiagAndArgs) { |
| 671 | if tr := p.opts.Tracing; tr != nil { |
no test coverage detected