fix(run): skip the cjs suggestion for mjs/mts modules (#26698)

Co-authored-by: David Sherret <dsherret@gmail.com>
This commit is contained in:
Mohammad Sulaiman 2025-03-05 19:29:41 +02:00 committed by Ryan Dahl
parent 2ddaafd762
commit 64a4003487
5 changed files with 28 additions and 0 deletions

View file

@ -309,6 +309,13 @@ fn get_suggestions_for_terminal_errors(e: &JsError) -> Vec<FixSuggestion> {
|| msg.contains("exports is not defined")
|| msg.contains("require is not defined")
{
if let Some(file_name) =
e.frames.first().and_then(|f| f.file_name.as_ref())
{
if file_name.ends_with(".mjs") || file_name.ends_with(".mts") {
return vec![];
}
}
return vec![
FixSuggestion::info_multiline(&[
cstr!("Deno supports CommonJS modules in <u>.cjs</> files, or when the closest"),