summaryrefslogtreecommitdiff
path: root/cli
diff options
context:
space:
mode:
Diffstat (limited to 'cli')
-rw-r--r--cli/Cargo.toml1
-rw-r--r--cli/node/errors.rs50
-rw-r--r--cli/node/mod.rs14
3 files changed, 7 insertions, 58 deletions
diff --git a/cli/Cargo.toml b/cli/Cargo.toml
index a2b9bafae..d37dc6488 100644
--- a/cli/Cargo.toml
+++ b/cli/Cargo.toml
@@ -80,7 +80,6 @@ libc = "=0.2.126"
log = { version = "=0.4.17", features = ["serde"] }
mitata = "=0.0.7"
monch = "=0.2.0"
-node_resolver = "=0.1.1"
notify = "=5.0.0-pre.15"
once_cell = "=1.12.0"
os_pipe = "=1.0.1"
diff --git a/cli/node/errors.rs b/cli/node/errors.rs
deleted file mode 100644
index f14e6e92e..000000000
--- a/cli/node/errors.rs
+++ /dev/null
@@ -1,50 +0,0 @@
-// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
-
-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,
- reason: &str,
- maybe_base: Option<String>,
-) -> AnyError {
- let mut msg = format!(
- "[ERR_INVALID_MODULE_SPECIFIER] Invalid module \"{}\" {}",
- request, reason
- );
-
- if let Some(base) = maybe_base {
- msg = format!("{} imported from {}", msg, base);
- }
-
- type_error(msg)
-}
-
-pub fn err_module_not_found(path: &str, base: &str, typ: &str) -> AnyError {
- generic_error(format!(
- "[ERR_MODULE_NOT_FOUND] Cannot find {} \"{}\" imported from \"{}\"",
- typ, path, base
- ))
-}
-
-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/cli/node/mod.rs b/cli/node/mod.rs
index c64ba6132..6e8b4bf13 100644
--- a/cli/node/mod.rs
+++ b/cli/node/mod.rs
@@ -17,6 +17,7 @@ use deno_core::serde_json::Value;
use deno_core::url::Url;
use deno_core::JsRuntime;
use deno_graph::source::ResolveResponse;
+use deno_runtime::deno_node::errors;
use deno_runtime::deno_node::get_closest_package_json;
use deno_runtime::deno_node::legacy_main_resolve;
use deno_runtime::deno_node::package_exports_resolve;
@@ -37,19 +38,18 @@ use crate::npm::NpmPackageReq;
use crate::npm::NpmPackageResolver;
mod analyze;
-pub mod errors;
pub use analyze::esm_code_with_node_globals;
-pub struct NodeModulePolyfill {
+struct NodeModulePolyfill {
/// Name of the module like "assert" or "timers/promises"
- pub name: &'static str,
+ name: &'static str,
/// Specifier relative to the root of `deno_std` repo, like "node/asser.ts"
- pub specifier: &'static str,
+ specifier: &'static str,
}
-pub(crate) static SUPPORTED_MODULES: &[NodeModulePolyfill] = &[
+static SUPPORTED_MODULES: &[NodeModulePolyfill] = &[
NodeModulePolyfill {
name: "assert",
specifier: "node/assert.ts",
@@ -224,7 +224,7 @@ pub(crate) static SUPPORTED_MODULES: &[NodeModulePolyfill] = &[
},
];
-pub(crate) static NODE_COMPAT_URL: Lazy<Url> = Lazy::new(|| {
+static NODE_COMPAT_URL: Lazy<Url> = Lazy::new(|| {
if let Ok(url_str) = std::env::var("DENO_NODE_COMPAT_URL") {
let url = Url::parse(&url_str).expect(
"Malformed DENO_NODE_COMPAT_URL value, make sure it's a file URL ending with a slash"
@@ -238,7 +238,7 @@ pub(crate) static NODE_COMPAT_URL: Lazy<Url> = Lazy::new(|| {
pub static MODULE_ALL_URL: Lazy<Url> =
Lazy::new(|| NODE_COMPAT_URL.join("node/module_all.ts").unwrap());
-pub fn try_resolve_builtin_module(specifier: &str) -> Option<Url> {
+fn try_resolve_builtin_module(specifier: &str) -> Option<Url> {
for module in SUPPORTED_MODULES {
if module.name == specifier {
let module_url = NODE_COMPAT_URL.join(module.specifier).unwrap();