Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Change hint for unresolved dependency. #2808

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion internal/bundler/bundler.go
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ func ResolveFailureErrorTextSuggestionNotes(
hint := ""

if resolver.IsPackagePath(path) && !fs.IsAbs(path) {
hint = fmt.Sprintf("You can mark the path %q as external to exclude it from the bundle, which will remove this error.", path)
hint = fmt.Sprintf("If you expect this dependency to be provided by your environment, ie. your browser or Node.JS, you can mark the path %q as external to exclude it from the bundle.", path)
if kind == ast.ImportRequire {
hint += " You can also surround this \"require\" call with a try/catch block to handle this failure at run-time instead of bundle-time."
} else if kind == ast.ImportDynamic {
Expand Down
4 changes: 2 additions & 2 deletions internal/bundler_tests/bundler_css_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -668,9 +668,9 @@ func TestCSSExternalQueryAndHashNoMatchIssue1822(t *testing.T) {
},
},
expectedScanLog: `entry.css: ERROR: Could not resolve "foo/bar.png?baz"
NOTE: You can mark the path "foo/bar.png?baz" as external to exclude it from the bundle, which will remove this error.
NOTE: If you expect this dependency to be provided by your environment, ie. your browser or Node.JS, you can mark the path "foo/bar.png?baz" as external to exclude it from the bundle.
entry.css: ERROR: Could not resolve "foo/bar.png#baz"
NOTE: You can mark the path "foo/bar.png#baz" as external to exclude it from the bundle, which will remove this error.
NOTE: If you expect this dependency to be provided by your environment, ie. your browser or Node.JS, you can mark the path "foo/bar.png#baz" as external to exclude it from the bundle.
`,
})
}
Expand Down
14 changes: 7 additions & 7 deletions internal/bundler_tests/bundler_default_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1290,7 +1290,7 @@ func TestImportInsideTry(t *testing.T) {
AbsOutputFile: "/out.js",
},
expectedScanLog: `entry.js: ERROR: Could not resolve "nope1"
NOTE: You can mark the path "nope1" as external to exclude it from the bundle, which will remove this error. You can also add ".catch()" here to handle this failure at run-time instead of bundle-time.
NOTE: If you expect this dependency to be provided by your environment, ie. your browser or Node.JS, you can mark the path "nope1" as external to exclude it from the bundle. You can also add ".catch()" here to handle this failure at run-time instead of bundle-time.
`,
})
}
Expand Down Expand Up @@ -2266,17 +2266,17 @@ func TestExternalModuleExclusionScopedPackage(t *testing.T) {
},
},
expectedScanLog: `index.js: ERROR: Could not resolve "@a1-a2"
NOTE: You can mark the path "@a1-a2" as external to exclude it from the bundle, which will remove this error.
NOTE: If you expect this dependency to be provided by your environment, ie. your browser or Node.JS, you can mark the path "@a1-a2" as external to exclude it from the bundle.
index.js: ERROR: Could not resolve "@b1"
NOTE: You can mark the path "@b1" as external to exclude it from the bundle, which will remove this error.
NOTE: If you expect this dependency to be provided by your environment, ie. your browser or Node.JS, you can mark the path "@b1" as external to exclude it from the bundle.
index.js: ERROR: Could not resolve "@b1/b2-b3"
NOTE: You can mark the path "@b1/b2-b3" as external to exclude it from the bundle, which will remove this error.
NOTE: If you expect this dependency to be provided by your environment, ie. your browser or Node.JS, you can mark the path "@b1/b2-b3" as external to exclude it from the bundle.
index.js: ERROR: Could not resolve "@c1"
NOTE: You can mark the path "@c1" as external to exclude it from the bundle, which will remove this error.
NOTE: If you expect this dependency to be provided by your environment, ie. your browser or Node.JS, you can mark the path "@c1" as external to exclude it from the bundle.
index.js: ERROR: Could not resolve "@c1/c2"
NOTE: You can mark the path "@c1/c2" as external to exclude it from the bundle, which will remove this error.
NOTE: If you expect this dependency to be provided by your environment, ie. your browser or Node.JS, you can mark the path "@c1/c2" as external to exclude it from the bundle.
index.js: ERROR: Could not resolve "@c1/c2/c3-c4"
NOTE: You can mark the path "@c1/c2/c3-c4" as external to exclude it from the bundle, which will remove this error.
NOTE: If you expect this dependency to be provided by your environment, ie. your browser or Node.JS, you can mark the path "@c1/c2/c3-c4" as external to exclude it from the bundle.
`,
})
}
Expand Down