diff --git a/runtime/fmt_errors.rs b/runtime/fmt_errors.rs index 6aa4765829..24248cd6bb 100644 --- a/runtime/fmt_errors.rs +++ b/runtime/fmt_errors.rs @@ -304,6 +304,13 @@ fn format_js_error_inner( } fn get_suggestions_for_terminal_errors(e: &JsError) -> Vec { + if let Some(frame) = e.frames.first() { + if let Some(file_name) = &frame.file_name { + if file_name.ends_with(".mjs") || file_name.ends_with(".mts") { + return vec![]; + } + } + } if let Some(msg) = &e.message { if msg.contains("module is not defined") || msg.contains("exports is not defined") diff --git a/tests/specs/fmt_errors/__test__.jsonc b/tests/specs/fmt_errors/__test__.jsonc new file mode 100644 index 0000000000..4f7e7e2b02 --- /dev/null +++ b/tests/specs/fmt_errors/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --unstable --allow-read main.mts", + "output": "main.out" +} diff --git a/tests/specs/fmt_errors/a.cts b/tests/specs/fmt_errors/a.cts new file mode 100644 index 0000000000..636d99af3a --- /dev/null +++ b/tests/specs/fmt_errors/a.cts @@ -0,0 +1,6 @@ +function add(num1, num2) { + const result = num1 + num2; + return result; +} + +module.exports = { add }; diff --git a/tests/specs/fmt_errors/main.mts b/tests/specs/fmt_errors/main.mts new file mode 100644 index 0000000000..50da134249 --- /dev/null +++ b/tests/specs/fmt_errors/main.mts @@ -0,0 +1,3 @@ +import * as a from "./a.cts"; + +console.log(a.add(1, 2)); diff --git a/tests/specs/fmt_errors/main.out b/tests/specs/fmt_errors/main.out new file mode 100644 index 0000000000..00750edc07 --- /dev/null +++ b/tests/specs/fmt_errors/main.out @@ -0,0 +1 @@ +3