summaryrefslogtreecommitdiff
path: root/ext/node
diff options
context:
space:
mode:
Diffstat (limited to 'ext/node')
-rw-r--r--ext/node/errors.rs21
-rw-r--r--ext/node/lib.rs8
2 files changed, 25 insertions, 4 deletions
diff --git a/ext/node/errors.rs b/ext/node/errors.rs
index 9dc6c7e7e..4b55d1982 100644
--- a/ext/node/errors.rs
+++ b/ext/node/errors.rs
@@ -3,6 +3,7 @@
use deno_core::error::generic_error;
use deno_core::error::type_error;
use deno_core::error::AnyError;
+use deno_core::url::Url;
pub fn err_invalid_module_specifier(
request: &str,
@@ -120,3 +121,23 @@ pub fn err_package_import_not_defined(
type_error(msg)
}
+
+pub fn err_unsupported_dir_import(path: &str, base: &str) -> AnyError {
+ generic_error(format!("[ERR_UNSUPPORTED_DIR_IMPORT] Directory import '{}' is not supported resolving ES modules imported from {}", path, base))
+}
+
+pub fn err_unsupported_esm_url_scheme(url: &Url) -> AnyError {
+ let mut msg =
+ "[ERR_UNSUPPORTED_ESM_URL_SCHEME] Only file and data URLS are supported by the default ESM loader"
+ .to_string();
+
+ if cfg!(window) && url.scheme().len() == 2 {
+ msg = format!(
+ "{}. On Windows, absolute path must be valid file:// URLs",
+ msg
+ );
+ }
+
+ msg = format!("{}. Received protocol '{}'", msg, url.scheme());
+ generic_error(msg)
+}
diff --git a/ext/node/lib.rs b/ext/node/lib.rs
index 6f3173470..99df93be5 100644
--- a/ext/node/lib.rs
+++ b/ext/node/lib.rs
@@ -11,6 +11,10 @@ use std::path::Path;
use std::path::PathBuf;
use std::rc::Rc;
+pub mod errors;
+mod package_json;
+mod resolution;
+
pub use package_json::PackageJson;
pub use resolution::get_closest_package_json;
pub use resolution::get_package_scope_config;
@@ -42,10 +46,6 @@ pub trait DenoDirNpmResolver {
fn ensure_read_permission(&self, path: &Path) -> Result<(), AnyError>;
}
-mod errors;
-mod package_json;
-mod resolution;
-
pub const MODULE_ES_SHIM: &str = include_str!("./module_es_shim.js");
struct Unstable(pub bool);