diff --git a/internal/bundler/bundler_default_test.go b/internal/bundler/bundler_default_test.go index 7b975d6af3f..7b3c1278d1b 100644 --- a/internal/bundler/bundler_default_test.go +++ b/internal/bundler/bundler_default_test.go @@ -494,7 +494,8 @@ func TestJSXSyntaxInJS(t *testing.T) { AbsOutputFile: "/out.js", }, expectedScanLog: `entry.js: ERROR: The JSX syntax extension is not currently enabled -NOTE: The esbuild loader for this file is currently set to "js" but it must be set to "jsx" to be able to parse JSX syntax. You can use 'Loader: map[string]api.Loader{".js": api.LoaderJSX}' to do that. +NOTE: The esbuild loader for this file is currently set to "js" but it must be set to "jsx" to be able to parse JSX syntax. ` + + `You can use 'Loader: map[string]api.Loader{".js": api.LoaderJSX}' to do that. `, }) } diff --git a/internal/bundler/bundler_packagejson_test.go b/internal/bundler/bundler_packagejson_test.go index b970b0534d9..bda62ea54a6 100644 --- a/internal/bundler/bundler_packagejson_test.go +++ b/internal/bundler/bundler_packagejson_test.go @@ -1236,19 +1236,19 @@ func TestPackageJsonExportsErrorInvalidModuleSpecifier(t *testing.T) { AbsOutputFile: "/Users/user/project/out.js", }, expectedScanLog: `Users/user/project/src/entry.js: ERROR: Could not resolve "pkg1" -Users/user/project/node_modules/pkg1/package.json: NOTE: The module specifier "./%%" is invalid +Users/user/project/node_modules/pkg1/package.json: NOTE: The module specifier "./%%" is invalid: NOTE: You can mark the path "pkg1" as external to exclude it from the bundle, which will remove this error. Users/user/project/src/entry.js: ERROR: Could not resolve "pkg2" -Users/user/project/node_modules/pkg2/package.json: NOTE: The module specifier "./%2f" is invalid +Users/user/project/node_modules/pkg2/package.json: NOTE: The module specifier "./%2f" is invalid: NOTE: You can mark the path "pkg2" as external to exclude it from the bundle, which will remove this error. Users/user/project/src/entry.js: ERROR: Could not resolve "pkg3" -Users/user/project/node_modules/pkg3/package.json: NOTE: The module specifier "./%2F" is invalid +Users/user/project/node_modules/pkg3/package.json: NOTE: The module specifier "./%2F" is invalid: NOTE: You can mark the path "pkg3" as external to exclude it from the bundle, which will remove this error. Users/user/project/src/entry.js: ERROR: Could not resolve "pkg4" -Users/user/project/node_modules/pkg4/package.json: NOTE: The module specifier "./%5c" is invalid +Users/user/project/node_modules/pkg4/package.json: NOTE: The module specifier "./%5c" is invalid: NOTE: You can mark the path "pkg4" as external to exclude it from the bundle, which will remove this error. Users/user/project/src/entry.js: ERROR: Could not resolve "pkg5" -Users/user/project/node_modules/pkg5/package.json: NOTE: The module specifier "./%5C" is invalid +Users/user/project/node_modules/pkg5/package.json: NOTE: The module specifier "./%5C" is invalid: NOTE: You can mark the path "pkg5" as external to exclude it from the bundle, which will remove this error. `, }) @@ -1309,13 +1309,13 @@ func TestPackageJsonExportsErrorInvalidPackageTarget(t *testing.T) { AbsOutputFile: "/Users/user/project/out.js", }, expectedScanLog: `Users/user/project/src/entry.js: ERROR: Could not resolve "pkg1" -Users/user/project/node_modules/pkg1/package.json: NOTE: The package target "invalid" is invalid +Users/user/project/node_modules/pkg1/package.json: NOTE: The package target "invalid" is invalid: NOTE: You can mark the path "pkg1" as external to exclude it from the bundle, which will remove this error. Users/user/project/src/entry.js: ERROR: Could not resolve "pkg2" -Users/user/project/node_modules/pkg2/package.json: NOTE: The package target "../pkg3" is invalid +Users/user/project/node_modules/pkg2/package.json: NOTE: The package target "../pkg3" is invalid: NOTE: You can mark the path "pkg2" as external to exclude it from the bundle, which will remove this error. Users/user/project/src/entry.js: ERROR: Could not resolve "pkg3" -Users/user/project/node_modules/pkg3/package.json: NOTE: The package target "./node_modules/pkg" is invalid +Users/user/project/node_modules/pkg3/package.json: NOTE: The package target "./node_modules/pkg" is invalid: NOTE: You can mark the path "pkg3" as external to exclude it from the bundle, which will remove this error. `, }) @@ -1337,7 +1337,7 @@ func TestPackageJsonExportsErrorPackagePathNotExported(t *testing.T) { AbsOutputFile: "/Users/user/project/out.js", }, expectedScanLog: `Users/user/project/src/entry.js: ERROR: Could not resolve "pkg1/foo" -Users/user/project/node_modules/pkg1/package.json: NOTE: The path "./foo" is not exported by package "pkg1" +Users/user/project/node_modules/pkg1/package.json: NOTE: The path "./foo" is not exported by package "pkg1": NOTE: You can mark the path "pkg1/foo" as external to exclude it from the bundle, which will remove this error. `, }) @@ -1359,7 +1359,7 @@ func TestPackageJsonExportsErrorModuleNotFound(t *testing.T) { AbsOutputFile: "/Users/user/project/out.js", }, expectedScanLog: `Users/user/project/src/entry.js: ERROR: Could not resolve "pkg1" -Users/user/project/node_modules/pkg1/package.json: NOTE: The module "./foo.js" was not found on the file system +Users/user/project/node_modules/pkg1/package.json: NOTE: The module "./foo.js" was not found on the file system: NOTE: You can mark the path "pkg1" as external to exclude it from the bundle, which will remove this error. `, }) @@ -1388,10 +1388,10 @@ func TestPackageJsonExportsErrorUnsupportedDirectoryImport(t *testing.T) { AbsOutputFile: "/Users/user/project/out.js", }, expectedScanLog: `Users/user/project/src/entry.js: ERROR: Could not resolve "pkg1" -Users/user/project/node_modules/pkg1/package.json: NOTE: The module "./foo" was not found on the file system +Users/user/project/node_modules/pkg1/package.json: NOTE: The module "./foo" was not found on the file system: NOTE: You can mark the path "pkg1" as external to exclude it from the bundle, which will remove this error. Users/user/project/src/entry.js: ERROR: Could not resolve "pkg2" -Users/user/project/node_modules/pkg2/package.json: NOTE: Importing the directory "./foo" is not supported +Users/user/project/node_modules/pkg2/package.json: NOTE: Importing the directory "./foo" is not supported: NOTE: You can mark the path "pkg2" as external to exclude it from the bundle, which will remove this error. `, }) @@ -1654,7 +1654,7 @@ func TestPackageJsonExportsWildcard(t *testing.T) { AbsOutputFile: "/Users/user/project/out.js", }, expectedScanLog: `Users/user/project/src/entry.js: ERROR: Could not resolve "pkg1/foo" -Users/user/project/node_modules/pkg1/package.json: NOTE: The path "./foo" is not exported by package "pkg1" +Users/user/project/node_modules/pkg1/package.json: NOTE: The path "./foo" is not exported by package "pkg1": NOTE: You can mark the path "pkg1/foo" as external to exclude it from the bundle, which will remove this error. `, }) @@ -1676,7 +1676,7 @@ func TestPackageJsonExportsErrorMissingTrailingSlash(t *testing.T) { AbsOutputFile: "/Users/user/project/out.js", }, expectedScanLog: `Users/user/project/src/entry.js: ERROR: Could not resolve "pkg1/foo/bar" -Users/user/project/node_modules/pkg1/package.json: NOTE: The module specifier "./test" is invalid +Users/user/project/node_modules/pkg1/package.json: NOTE: The module specifier "./test" is invalid: NOTE: You can mark the path "pkg1/foo/bar" as external to exclude it from the bundle, which will remove this error. `, }) @@ -1758,7 +1758,7 @@ func TestPackageJsonExportsNotExactMissingExtensionPattern(t *testing.T) { AbsOutputFile: "/Users/user/project/out.js", }, expectedScanLog: `Users/user/project/src/entry.js: ERROR: Could not resolve "pkg1/foo/bar" -Users/user/project/node_modules/pkg1/package.json: NOTE: The module "./dir/bar" was not found on the file system +Users/user/project/node_modules/pkg1/package.json: NOTE: The module "./dir/bar" was not found on the file system: NOTE: You can mark the path "pkg1/foo/bar" as external to exclude it from the bundle, which will remove this error. `, }) @@ -1787,7 +1787,7 @@ func TestPackageJsonExportsExactMissingExtension(t *testing.T) { AbsOutputFile: "/Users/user/project/out.js", }, expectedScanLog: `Users/user/project/src/entry.js: ERROR: Could not resolve "pkg1/foo/bar" -Users/user/project/node_modules/pkg1/package.json: NOTE: The module "./dir/bar" was not found on the file system +Users/user/project/node_modules/pkg1/package.json: NOTE: The module "./dir/bar" was not found on the file system: NOTE: You can mark the path "pkg1/foo/bar" as external to exclude it from the bundle, which will remove this error. `, }) @@ -1822,12 +1822,12 @@ func TestPackageJsonExportsNoConditionsMatch(t *testing.T) { AbsOutputFile: "/Users/user/project/out.js", }, expectedScanLog: `Users/user/project/src/entry.js: ERROR: Could not resolve "pkg1" -Users/user/project/node_modules/pkg1/package.json: NOTE: The path "." is not currently exported by package "pkg1" -Users/user/project/node_modules/pkg1/package.json: NOTE: None of the conditions provided ("what") match any of the currently active conditions ("browser", "default", "import") +Users/user/project/node_modules/pkg1/package.json: NOTE: The path "." is not currently exported by package "pkg1": +Users/user/project/node_modules/pkg1/package.json: NOTE: None of the conditions provided ("what") match any of the currently active conditions ("browser", "default", "import"): NOTE: You can mark the path "pkg1" as external to exclude it from the bundle, which will remove this error. Users/user/project/src/entry.js: ERROR: Could not resolve "pkg1/foo.js" -Users/user/project/node_modules/pkg1/package.json: NOTE: The path "./foo.js" is not currently exported by package "pkg1" -Users/user/project/node_modules/pkg1/package.json: NOTE: None of the conditions provided ("what") match any of the currently active conditions ("browser", "default", "import") +Users/user/project/node_modules/pkg1/package.json: NOTE: The path "./foo.js" is not currently exported by package "pkg1": +Users/user/project/node_modules/pkg1/package.json: NOTE: None of the conditions provided ("what") match any of the currently active conditions ("browser", "default", "import"): NOTE: You can mark the path "pkg1/foo.js" as external to exclude it from the bundle, which will remove this error. `, }) @@ -1862,14 +1862,14 @@ func TestPackageJsonExportsMustUseRequire(t *testing.T) { AbsOutputFile: "/Users/user/project/out.js", }, expectedScanLog: `Users/user/project/src/entry.js: ERROR: Could not resolve "pkg1" -Users/user/project/node_modules/pkg1/package.json: NOTE: The path "." is not currently exported by package "pkg1" -Users/user/project/node_modules/pkg1/package.json: NOTE: None of the conditions provided ("require") match any of the currently active conditions ("browser", "default", "import") -Users/user/project/src/entry.js: NOTE: Consider using a "require()" call to import this file +Users/user/project/node_modules/pkg1/package.json: NOTE: The path "." is not currently exported by package "pkg1": +Users/user/project/node_modules/pkg1/package.json: NOTE: None of the conditions provided ("require") match any of the currently active conditions ("browser", "default", "import"): +Users/user/project/src/entry.js: NOTE: Consider using a "require()" call to import this file: NOTE: You can mark the path "pkg1" as external to exclude it from the bundle, which will remove this error. Users/user/project/src/entry.js: ERROR: Could not resolve "pkg1/foo.js" -Users/user/project/node_modules/pkg1/package.json: NOTE: The path "./foo.js" is not currently exported by package "pkg1" -Users/user/project/node_modules/pkg1/package.json: NOTE: None of the conditions provided ("require") match any of the currently active conditions ("browser", "default", "import") -Users/user/project/src/entry.js: NOTE: Consider using a "require()" call to import this file +Users/user/project/node_modules/pkg1/package.json: NOTE: The path "./foo.js" is not currently exported by package "pkg1": +Users/user/project/node_modules/pkg1/package.json: NOTE: None of the conditions provided ("require") match any of the currently active conditions ("browser", "default", "import"): +Users/user/project/src/entry.js: NOTE: Consider using a "require()" call to import this file: NOTE: You can mark the path "pkg1/foo.js" as external to exclude it from the bundle, which will remove this error. `, }) @@ -1904,14 +1904,14 @@ func TestPackageJsonExportsMustUseImport(t *testing.T) { AbsOutputFile: "/Users/user/project/out.js", }, expectedScanLog: `Users/user/project/src/entry.js: ERROR: Could not resolve "pkg1" -Users/user/project/node_modules/pkg1/package.json: NOTE: The path "." is not currently exported by package "pkg1" -Users/user/project/node_modules/pkg1/package.json: NOTE: None of the conditions provided ("import") match any of the currently active conditions ("browser", "default", "require") -Users/user/project/src/entry.js: NOTE: Consider using an "import" statement to import this file +Users/user/project/node_modules/pkg1/package.json: NOTE: The path "." is not currently exported by package "pkg1": +Users/user/project/node_modules/pkg1/package.json: NOTE: None of the conditions provided ("import") match any of the currently active conditions ("browser", "default", "require"): +Users/user/project/src/entry.js: NOTE: Consider using an "import" statement to import this file: NOTE: You can mark the path "pkg1" as external to exclude it from the bundle, which will remove this error. You can also surround this "require" call with a try/catch block to handle this failure at run-time instead of bundle-time. Users/user/project/src/entry.js: ERROR: Could not resolve "pkg1/foo.js" -Users/user/project/node_modules/pkg1/package.json: NOTE: The path "./foo.js" is not currently exported by package "pkg1" -Users/user/project/node_modules/pkg1/package.json: NOTE: None of the conditions provided ("import") match any of the currently active conditions ("browser", "default", "require") -Users/user/project/src/entry.js: NOTE: Consider using an "import" statement to import this file +Users/user/project/node_modules/pkg1/package.json: NOTE: The path "./foo.js" is not currently exported by package "pkg1": +Users/user/project/node_modules/pkg1/package.json: NOTE: None of the conditions provided ("import") match any of the currently active conditions ("browser", "default", "require"): +Users/user/project/src/entry.js: NOTE: Consider using an "import" statement to import this file: NOTE: You can mark the path "pkg1/foo.js" as external to exclude it from the bundle, which will remove this error. You can also surround this "require" call with a try/catch block to handle this failure at run-time instead of bundle-time. `, }) @@ -1945,14 +1945,14 @@ func TestPackageJsonExportsReverseLookup(t *testing.T) { AbsOutputFile: "/Users/user/project/out.js", }, expectedScanLog: `Users/user/project/src/entry.js: ERROR: Could not resolve "pkg/path/to/real/file" -Users/user/project/node_modules/pkg/package.json: NOTE: The path "./path/to/real/file" is not exported by package "pkg" -Users/user/project/node_modules/pkg/package.json: NOTE: The file "./path/to/real/file.js" is exported at path "./lib/teal/file" -Users/user/project/src/entry.js: NOTE: Import from "pkg/lib/teal/file" to get the file "Users/user/project/node_modules/pkg/path/to/real/file.js" +Users/user/project/node_modules/pkg/package.json: NOTE: The path "./path/to/real/file" is not exported by package "pkg": +Users/user/project/node_modules/pkg/package.json: NOTE: The file "./path/to/real/file.js" is exported at path "./lib/teal/file": +Users/user/project/src/entry.js: NOTE: Import from "pkg/lib/teal/file" to get the file "Users/user/project/node_modules/pkg/path/to/real/file.js": NOTE: You can mark the path "pkg/path/to/real/file" as external to exclude it from the bundle, which will remove this error. You can also surround this "require" call with a try/catch block to handle this failure at run-time instead of bundle-time. Users/user/project/src/entry.js: ERROR: Could not resolve "pkg/path/to/other/file" -Users/user/project/node_modules/pkg/package.json: NOTE: The path "./path/to/other/file" is not exported by package "pkg" -Users/user/project/node_modules/pkg/package.json: NOTE: The file "./path/to/other/file.js" is exported at path "./extra/other/file.js" -Users/user/project/src/entry.js: NOTE: Import from "pkg/extra/other/file.js" to get the file "Users/user/project/node_modules/pkg/path/to/other/file.js" +Users/user/project/node_modules/pkg/package.json: NOTE: The path "./path/to/other/file" is not exported by package "pkg": +Users/user/project/node_modules/pkg/package.json: NOTE: The file "./path/to/other/file.js" is exported at path "./extra/other/file.js": +Users/user/project/src/entry.js: NOTE: Import from "pkg/extra/other/file.js" to get the file "Users/user/project/node_modules/pkg/path/to/other/file.js": NOTE: You can mark the path "pkg/path/to/other/file" as external to exclude it from the bundle, which will remove this error. You can also surround this "require" call with a try/catch block to handle this failure at run-time instead of bundle-time. `, }) @@ -2042,7 +2042,7 @@ func TestPackageJsonImportsErrorMissingRemappedPackage(t *testing.T) { AbsOutputFile: "/Users/user/project/out.js", }, expectedScanLog: `Users/user/project/src/entry.js: ERROR: Could not resolve "#foo" -Users/user/project/src/package.json: NOTE: The remapped path "bar" could not be resolved +Users/user/project/src/package.json: NOTE: The remapped path "bar" could not be resolved: NOTE: You can mark the path "#foo" as external to exclude it from the bundle, which will remove this error. `, }) @@ -2091,7 +2091,7 @@ func TestPackageJsonImportsErrorEqualsHash(t *testing.T) { AbsOutputFile: "/Users/user/project/out.js", }, expectedScanLog: `Users/user/project/src/entry.js: ERROR: Could not resolve "#" -Users/user/project/src/package.json: NOTE: This "imports" map was ignored because the module specifier "#" is invalid +Users/user/project/src/package.json: NOTE: This "imports" map was ignored because the module specifier "#" is invalid: NOTE: You can mark the path "#" as external to exclude it from the bundle, which will remove this error. `, }) @@ -2115,7 +2115,7 @@ func TestPackageJsonImportsErrorStartsWithHashSlash(t *testing.T) { AbsOutputFile: "/Users/user/project/out.js", }, expectedScanLog: `Users/user/project/src/entry.js: ERROR: Could not resolve "#/foo" -Users/user/project/src/package.json: NOTE: This "imports" map was ignored because the module specifier "#/foo" is invalid +Users/user/project/src/package.json: NOTE: This "imports" map was ignored because the module specifier "#/foo" is invalid: NOTE: You can mark the path "#/foo" as external to exclude it from the bundle, which will remove this error. `, }) diff --git a/internal/logger/logger.go b/internal/logger/logger.go index 7ed922bef44..ae79e85efb6 100644 --- a/internal/logger/logger.go +++ b/internal/logger/logger.go @@ -1043,17 +1043,17 @@ func msgString(includeSource bool, terminalInfo TerminalInfo, kind MsgKind, data maxMargin := len(fmt.Sprintf("%d", data.Location.Line)) d := detailStruct(data, terminalInfo, maxMargin) if d.Suggestion != "" { - location = fmt.Sprintf("\n %s%s:%d:%d:\n%s%s%s%s%s\n%s%s%s%s%s\n%s%s%s%s%s\n%s", - colors.Dim, d.Path, d.Line, d.Column, - d.SourceBefore, colors.Green, d.SourceMarked, colors.Dim, d.SourceAfter, + location = fmt.Sprintf("\n %s:%d:%d:\n%s%s%s%s%s%s\n%s%s%s%s%s\n%s%s%s%s%s\n%s", + d.Path, d.Line, d.Column, + colors.Dim, d.SourceBefore, colors.Green, d.SourceMarked, colors.Dim, d.SourceAfter, emptyMarginText(maxMargin, false), d.Indent, colors.Green, d.Marker, colors.Dim, emptyMarginText(maxMargin, true), d.Indent, colors.Green, d.Suggestion, colors.Reset, d.ContentAfter, ) } else { - location = fmt.Sprintf("\n %s%s:%d:%d:\n%s%s%s%s%s\n%s%s%s%s%s\n%s", - colors.Dim, d.Path, d.Line, d.Column, - d.SourceBefore, colors.Green, d.SourceMarked, colors.Dim, d.SourceAfter, + location = fmt.Sprintf("\n %s:%d:%d:\n%s%s%s%s%s%s\n%s%s%s%s%s\n%s", + d.Path, d.Line, d.Column, + colors.Dim, d.SourceBefore, colors.Green, d.SourceMarked, colors.Dim, d.SourceAfter, emptyMarginText(maxMargin, true), d.Indent, colors.Green, d.Marker, colors.Reset, d.ContentAfter, ) diff --git a/internal/resolver/package_json.go b/internal/resolver/package_json.go index f78cd1e1c80..6f12c5a90f0 100644 --- a/internal/resolver/package_json.go +++ b/internal/resolver/package_json.go @@ -257,8 +257,10 @@ func (r resolverQuery) parsePackageJSON(inputPath string) *packageJSON { case "module": packageJSON.moduleType = config.ModuleESM default: - r.log.Add(logger.Warning, &tracker, jsonSource.RangeOfString(typeJSON.Loc), - fmt.Sprintf("%q is not a valid value for the \"type\" field (must be either \"commonjs\" or \"module\")", typeValue)) + r.log.AddWithNotes(logger.Warning, &tracker, jsonSource.RangeOfString(typeJSON.Loc), + fmt.Sprintf("%q is not a valid value for the \"type\" field", typeValue), + []logger.MsgData{{Text: "The \"type\" field must be set to either \"commonjs\" or \"module\"."}}, + ) } } else { r.log.Add(logger.Warning, &tracker, logger.Range{Loc: typeJSON.Loc}, @@ -566,7 +568,7 @@ func parseImportsExportsMap(source logger.Source, log logger.Log, json js_ast.Ex log.AddWithNotes(logger.Warning, &tracker, keyRange, "This object cannot contain keys that both start with \".\" and don't start with \".\"", []logger.MsgData{tracker.MsgData(prevEntry.keyRange, - fmt.Sprintf("The previous key %q is incompatible with the current key %q", prevEntry.key, key))}) + fmt.Sprintf("The key %q is incompatible with the previous key %q:", key, prevEntry.key))}) return pjEntry{ kind: pjInvalid, firstToken: firstToken, @@ -607,7 +609,8 @@ func parseImportsExportsMap(source logger.Source, log logger.Log, json js_ast.Ex firstToken.Loc = expr.Loc } - log.Add(logger.Warning, &tracker, firstToken, "This value must be a string, an object, an array, or null") + log.Add(logger.Warning, &tracker, firstToken, + "This value must be a string, an object, an array, or null") return pjEntry{ kind: pjInvalid, firstToken: firstToken, diff --git a/internal/resolver/resolver.go b/internal/resolver/resolver.go index 70c10b93388..814cedbe455 100644 --- a/internal/resolver/resolver.go +++ b/internal/resolver/resolver.go @@ -1597,11 +1597,11 @@ func (r resolverQuery) loadNodeModules(importPath string, dirInfo *dirInfo, forb // a better error message instead of later when we're inside the algorithm if importPath == "#" || strings.HasPrefix(importPath, "#/") { if r.debugLogs != nil { - r.debugLogs.addNote(fmt.Sprintf("The path %q must not equal \"#\" and must not start with \"#/\"", importPath)) + r.debugLogs.addNote(fmt.Sprintf("The path %q must not equal \"#\" and must not start with \"#/\".", importPath)) } tracker := logger.MakeLineColumnTracker(&packageJSON.source) r.debugMeta.notes = append(r.debugMeta.notes, tracker.MsgData(packageJSON.importsMap.root.firstToken, - fmt.Sprintf("This \"imports\" map was ignored because the module specifier %q is invalid", importPath))) + fmt.Sprintf("This \"imports\" map was ignored because the module specifier %q is invalid:", importPath))) return PathPair{}, false, nil } @@ -1626,7 +1626,7 @@ func (r resolverQuery) loadNodeModules(importPath string, dirInfo *dirInfo, forb tracker := logger.MakeLineColumnTracker(&packageJSON.source) r.debugMeta.notes = append( []logger.MsgData{tracker.MsgData(debug.token, - fmt.Sprintf("The remapped path %q could not be resolved", resolvedPath))}, + fmt.Sprintf("The remapped path %q could not be resolved:", resolvedPath))}, r.debugMeta.notes...) } return absolute, ok, diffCase @@ -1798,14 +1798,14 @@ func (r resolverQuery) finalizeImportsExportsResult( switch status { case pjStatusInvalidModuleSpecifier: r.debugMeta.notes = []logger.MsgData{tracker.MsgData(debug.token, - fmt.Sprintf("The module specifier %q is invalid", resolvedPath))} + fmt.Sprintf("The module specifier %q is invalid:", resolvedPath))} case pjStatusInvalidPackageConfiguration: r.debugMeta.notes = []logger.MsgData{tracker.MsgData(debug.token, "The package configuration has an invalid value here:")} case pjStatusInvalidPackageTarget: - why := fmt.Sprintf("The package target %q is invalid", resolvedPath) + why := fmt.Sprintf("The package target %q is invalid:", resolvedPath) if resolvedPath == "" { // "PACKAGE_TARGET_RESOLVE" is specified to throw an "Invalid // Package Target" error for what is actually an invalid package @@ -1816,7 +1816,7 @@ func (r resolverQuery) finalizeImportsExportsResult( case pjStatusPackagePathNotExported: r.debugMeta.notes = []logger.MsgData{tracker.MsgData(debug.token, - fmt.Sprintf("The path %q is not exported by package %q", esmPackageSubpath, esmPackageName))} + fmt.Sprintf("The path %q is not exported by package %q:", esmPackageSubpath, esmPackageName))} // If this fails, try to resolve it using the old algorithm if absolute, ok, _ := r.loadAsFileOrDirectory(absImportPath); ok && absolute.Primary.Namespace == "file" { @@ -1828,12 +1828,12 @@ func (r resolverQuery) finalizeImportsExportsResult( if ok, subpath, token := r.esmPackageExportsReverseResolve( query, importExportMap.root, conditions); ok { r.debugMeta.notes = append(r.debugMeta.notes, tracker.MsgData(token, - fmt.Sprintf("The file %q is exported at path %q", query, subpath))) + fmt.Sprintf("The file %q is exported at path %q:", query, subpath))) // Provide an inline suggestion message with the correct import path actualImportPath := path.Join(esmPackageName, subpath) r.debugMeta.suggestionText = string(js_printer.QuoteForJSON(actualImportPath, false)) - r.debugMeta.suggestionMessage = fmt.Sprintf("Import from %q to get the file %q", + r.debugMeta.suggestionMessage = fmt.Sprintf("Import from %q to get the file %q:", actualImportPath, r.PrettyPath(absolute.Primary)) } } @@ -1841,15 +1841,15 @@ func (r resolverQuery) finalizeImportsExportsResult( case pjStatusPackageImportNotDefined: r.debugMeta.notes = []logger.MsgData{tracker.MsgData(debug.token, - fmt.Sprintf("The package import %q is not defined in this \"imports\" map", resolvedPath))} + fmt.Sprintf("The package import %q is not defined in this \"imports\" map:", resolvedPath))} case pjStatusModuleNotFound: r.debugMeta.notes = []logger.MsgData{tracker.MsgData(debug.token, - fmt.Sprintf("The module %q was not found on the file system", resolvedPath))} + fmt.Sprintf("The module %q was not found on the file system:", resolvedPath))} case pjStatusUnsupportedDirectoryImport: r.debugMeta.notes = []logger.MsgData{tracker.MsgData(debug.token, - fmt.Sprintf("Importing the directory %q is not supported", resolvedPath))} + fmt.Sprintf("Importing the directory %q is not supported:", resolvedPath))} case pjStatusUndefinedNoConditionsMatch: prettyPrintConditions := func(conditions []string) string { @@ -1866,18 +1866,18 @@ func (r resolverQuery) finalizeImportsExportsResult( sort.Strings(keys) r.debugMeta.notes = []logger.MsgData{ tracker.MsgData(importExportMap.root.firstToken, - fmt.Sprintf("The path %q is not currently exported by package %q", + fmt.Sprintf("The path %q is not currently exported by package %q:", esmPackageSubpath, esmPackageName)), tracker.MsgData(debug.token, - fmt.Sprintf("None of the conditions provided (%s) match any of the currently active conditions (%s)", + fmt.Sprintf("None of the conditions provided (%s) match any of the currently active conditions (%s):", prettyPrintConditions(debug.unmatchedConditions), prettyPrintConditions(keys), ))} for _, key := range debug.unmatchedConditions { if key == "import" && (r.kind == ast.ImportRequire || r.kind == ast.ImportRequireResolve) { - r.debugMeta.suggestionMessage = "Consider using an \"import\" statement to import this file" + r.debugMeta.suggestionMessage = "Consider using an \"import\" statement to import this file:" } else if key == "require" && (r.kind == ast.ImportStmt || r.kind == ast.ImportDynamic) { - r.debugMeta.suggestionMessage = "Consider using a \"require()\" call to import this file" + r.debugMeta.suggestionMessage = "Consider using a \"require()\" call to import this file:" } } }