diff --git a/cli/file_fetcher.rs b/cli/file_fetcher.rs index 95d778f0bb..640f83c35c 100644 --- a/cli/file_fetcher.rs +++ b/cli/file_fetcher.rs @@ -164,8 +164,19 @@ fn get_validated_scheme( ) -> Result { let scheme = specifier.scheme(); if !SUPPORTED_SCHEMES.contains(&scheme) { + // NOTE(bartlomieju): this message list additional `npm` and `jsr` schemes, but they should actually be handled + // before `file_fetcher.rs` APIs are even hit. + let mut all_supported_schemes = SUPPORTED_SCHEMES.to_vec(); + all_supported_schemes.extend_from_slice(&["npm", "jsr"]); + all_supported_schemes.sort(); + let scheme_list = all_supported_schemes + .iter() + .map(|scheme| format!(" - \"{}\"", scheme)) + .collect::>() + .join("\n"); Err(generic_error(format!( - "Unsupported scheme \"{scheme}\" for module \"{specifier}\". Supported schemes: {SUPPORTED_SCHEMES:#?}" + "Unsupported scheme \"{scheme}\" for module \"{specifier}\". Supported schemes:\n{}", + scheme_list ))) } else { Ok(scheme.to_string()) diff --git a/tests/specs/npm/typo_in_npm/__test__.jsonc b/tests/specs/npm/typo_in_npm/__test__.jsonc new file mode 100644 index 0000000000..03023c9e7a --- /dev/null +++ b/tests/specs/npm/typo_in_npm/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run np:cowsay", + "output": "main.out", + "exitCode": 1 +} diff --git a/tests/specs/npm/typo_in_npm/main.out b/tests/specs/npm/typo_in_npm/main.out new file mode 100644 index 0000000000..19f17b1d05 --- /dev/null +++ b/tests/specs/npm/typo_in_npm/main.out @@ -0,0 +1,8 @@ +error: Unsupported scheme "np" for module "np:cowsay". Supported schemes: + - "blob" + - "data" + - "file" + - "http" + - "https" + - "jsr" + - "npm" diff --git a/tests/specs/run/unsupported_dynamic_import_scheme/unsupported_dynamic_import_scheme.out b/tests/specs/run/unsupported_dynamic_import_scheme/unsupported_dynamic_import_scheme.out index c708fced49..3bff0201f9 100644 --- a/tests/specs/run/unsupported_dynamic_import_scheme/unsupported_dynamic_import_scheme.out +++ b/tests/specs/run/unsupported_dynamic_import_scheme/unsupported_dynamic_import_scheme.out @@ -1,7 +1,8 @@ -error: Uncaught (in promise) TypeError: Unsupported scheme "xxx" for module "xxx:". Supported schemes: [ - "data", - "blob", - "file", - "http", - "https", -] +error: Uncaught (in promise) TypeError: Unsupported scheme "xxx" for module "xxx:". Supported schemes: + - "blob" + - "data" + - "file" + - "http" + - "https" + - "jsr" + - "npm" diff --git a/tests/testdata/run/extension_import.ts.out b/tests/testdata/run/extension_import.ts.out index 88039a9ce8..0ff656a9c8 100644 --- a/tests/testdata/run/extension_import.ts.out +++ b/tests/testdata/run/extension_import.ts.out @@ -1,8 +1,9 @@ -error: Unsupported scheme "ext" for module "ext:runtime/01_errors.js". Supported schemes: [ - "data", - "blob", - "file", - "http", - "https", -] +error: Unsupported scheme "ext" for module "ext:runtime/01_errors.js". Supported schemes: + - "blob" + - "data" + - "file" + - "http" + - "https" + - "jsr" + - "npm" at [WILDCARD]/extension_import.ts:1:8