Skip to content

Commit

Permalink
resolver: improve some debug logging
Browse files Browse the repository at this point in the history
  • Loading branch information
evanw committed Mar 14, 2024
1 parent b0765ae commit cf42954
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions internal/resolver/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,9 @@ func NewResolver(call config.APICall, fs fs.FS, log logger.Log, caches *cache.Ca
visited = make(map[string]bool)
}
if options.TSConfigPath != "" {
if r.log.Level <= logger.LevelDebug {
r.debugLogs = &debugLogs{what: fmt.Sprintf("Resolving tsconfig file %q", options.TSConfigPath)}
}
res.tsConfigOverride, err = r.parseTSConfig(options.TSConfigPath, visited)
} else {
source := logger.Source{
Expand All @@ -345,6 +348,8 @@ func NewResolver(call config.APICall, fs fs.FS, log logger.Log, caches *cache.Ca
r.log.AddError(nil, logger.Range{}, fmt.Sprintf("Cannot read file %q: %s",
PrettyPath(r.fs, logger.Path{Text: options.TSConfigPath, Namespace: "file"}), err.Error()))
}
} else {
r.flushDebugLogs(flushDueToSuccess)
}
}

Expand Down Expand Up @@ -1402,8 +1407,12 @@ func (r resolverQuery) parseTSConfigFromSource(source logger.Source, visited map
// Suppress warnings about missing base config files inside "node_modules"
pnpError:
if !helpers.IsInsideNodeModules(source.KeyPath.Text) {
r.log.AddID(logger.MsgID_TSConfigJSON_Missing, logger.Warning, &tracker, extendsRange,
fmt.Sprintf("Cannot find base config file %q", extends))
var notes []logger.MsgData
if r.debugLogs != nil {
notes = r.debugLogs.notes
}
r.log.AddIDWithNotes(logger.MsgID_TSConfigJSON_Missing, logger.Warning, &tracker, extendsRange,
fmt.Sprintf("Cannot find base config file %q", extends), notes)
}

return nil
Expand Down

0 comments on commit cf42954

Please sign in to comment.