( export *Export, userPreferences modulespecifiers.UserPreferences, )
| 7 | ) |
| 8 | |
| 9 | func (v *View) GetModuleSpecifier( |
| 10 | export *Export, |
| 11 | userPreferences modulespecifiers.UserPreferences, |
| 12 | ) (string, modulespecifiers.ResultKind) { |
| 13 | // Ambient module |
| 14 | if modulespecifiers.PathIsBareSpecifier(string(export.ModuleID)) { |
| 15 | specifier := string(export.ModuleID) |
| 16 | if modulespecifiers.IsExcludedByRegex(specifier, userPreferences.AutoImportSpecifierExcludeRegexes) { |
| 17 | return "", modulespecifiers.ResultKindNone |
| 18 | } |
| 19 | return string(export.ModuleID), modulespecifiers.ResultKindAmbient |
| 20 | } |
| 21 | |
| 22 | if export.PackageName != "" { |
| 23 | if entrypoints, ok := v.registry.entrypoints[export.Path]; ok { |
| 24 | for _, entrypoint := range entrypoints { |
| 25 | if entrypoint.IncludeConditions.IsSubsetOf(v.conditions) && !v.conditions.Intersects(entrypoint.ExcludeConditions) { |
| 26 | specifier := modulespecifiers.ProcessEntrypointEnding( |
| 27 | entrypoint, |
| 28 | userPreferences, |
| 29 | v.program, |
| 30 | v.program.Options(), |
| 31 | v.importingFile, |
| 32 | v.getAllowedEndings(), |
| 33 | ) |
| 34 | |
| 35 | if !modulespecifiers.IsExcludedByRegex(specifier, userPreferences.AutoImportSpecifierExcludeRegexes) { |
| 36 | return specifier, modulespecifiers.ResultKindNodeModules |
| 37 | } |
| 38 | } |
| 39 | } |
| 40 | return "", modulespecifiers.ResultKindNone |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | cache := v.registry.specifierCache[v.importingFile.Path()] |
| 45 | if export.PackageName == "" { |
| 46 | if specifier, ok := cache.Load(export.Path); ok { |
| 47 | if specifier == "" { |
| 48 | return "", modulespecifiers.ResultKindNone |
| 49 | } |
| 50 | return specifier, modulespecifiers.ResultKindRelative |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | specifiers, kind := modulespecifiers.GetModuleSpecifiersForFileWithInfo( |
| 55 | v.importingFile, |
| 56 | export.ModuleFileName, |
| 57 | v.program.Options(), |
| 58 | v.program, |
| 59 | userPreferences, |
| 60 | modulespecifiers.ModuleSpecifierOptions{}, |
| 61 | true, |
| 62 | ) |
| 63 | // !!! unsure when this could return multiple specifiers combined with the |
| 64 | // new node_modules code. Possibly with local symlinks, which should be |
| 65 | // very rare. |
| 66 | for _, specifier := range specifiers { |
no test coverage detected