diff --git a/pkg/js/js.go b/pkg/js/js.go index 5a46c26e7..3c57a752d 100644 --- a/pkg/js/js.go +++ b/pkg/js/js.go @@ -59,12 +59,7 @@ const __dirname = topLevelFileUrlToPath(new topLevelURL(".", import.meta.url)) }) if len(result.Errors) > 0 { for _, err := range result.Errors { - slog.Error("esbuild error", - "text", err.Text, - "location.file", err.Location.File, - "location.line", err.Location.Line, - "column", err.Location.Column, - ) + slog.Error("esbuild error", "text", err.Text) } return result, fmt.Errorf("%s", FormatError(result.Errors)) } @@ -76,6 +71,10 @@ const __dirname = topLevelFileUrlToPath(new topLevelURL(".", import.meta.url)) func FormatError(input []esbuild.Message) string { lines := []string{} for _, err := range input { + if err.Location == nil { + lines = append(lines, fmt.Sprintf("%v", err.Text)) + continue + } lines = append(lines, fmt.Sprintf("%v:%v:%v: %v", err.Location.File, err.Location.Line, err.Location.Column, err.Text)) } return strings.Join(lines, "\n")