diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2024-03-07 13:59:57 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-07 14:59:57 +0100 |
commit | f0ec4fe1b89215ce9e62ebf47d8907dd6336f35e (patch) | |
tree | 0e74627f21ebba6393f7f48b5618435af5cd94ad /cli/resolver.rs | |
parent | 588dd5e66961999cfafd4504444e685629a92173 (diff) |
fix(publish): silence warnings for sloppy imports and node builtins with env var (#22760)
An undocumented "DENO_DISABLE_PEDANTIC_NODE_WARNINGS" env
var can be used to silence warnings for sloppy imports and node builtins
without `node:` prefix.
Diffstat (limited to 'cli/resolver.rs')
-rw-r--r-- | cli/resolver.rs | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/cli/resolver.rs b/cli/resolver.rs index e1a2145d3..8043e1ede 100644 --- a/cli/resolver.rs +++ b/cli/resolver.rs @@ -41,6 +41,7 @@ use std::sync::Arc; use crate::args::package_json::PackageJsonDeps; use crate::args::JsxImportSourceConfig; use crate::args::PackageJsonDepsProvider; +use crate::args::DENO_DISABLE_PEDANTIC_NODE_WARNINGS; use crate::colors; use crate::node::CliNodeCodeTranslator; use crate::npm::ByonmCliNpmResolver; @@ -725,17 +726,20 @@ fn sloppy_imports_resolve( }; // show a warning when this happens in order to drive // the user towards correcting these specifiers - log::warn!( - "{} Sloppy module resolution {}\n at {}", - crate::colors::yellow("Warning"), - crate::colors::gray(format!("(hint: {})", hint_message)).to_string(), - if referrer_range.end == deno_graph::Position::zeroed() { - // not worth showing the range in this case - crate::colors::cyan(referrer_range.specifier.as_str()).to_string() - } else { - format_range_with_colors(referrer_range) - }, - ); + if !*DENO_DISABLE_PEDANTIC_NODE_WARNINGS { + log::warn!( + "{} Sloppy module resolution {}\n at {}", + crate::colors::yellow("Warning"), + crate::colors::gray(format!("(hint: {})", hint_message)).to_string(), + if referrer_range.end == deno_graph::Position::zeroed() { + // not worth showing the range in this case + crate::colors::cyan(referrer_range.specifier.as_str()).to_string() + } else { + format_range_with_colors(referrer_range) + }, + ); + } + resolution.into_specifier().into_owned() } @@ -788,7 +792,9 @@ impl NpmResolver for CliGraphResolver { } = range; let line = start.line + 1; let column = start.character + 1; - log::warn!("Warning: Resolving \"{module_name}\" as \"node:{module_name}\" at {specifier}:{line}:{column}. If you want to use a built-in Node module, add a \"node:\" prefix.") + if !*DENO_DISABLE_PEDANTIC_NODE_WARNINGS { + log::warn!("Warning: Resolving \"{module_name}\" as \"node:{module_name}\" at {specifier}:{line}:{column}. If you want to use a built-in Node module, add a \"node:\" prefix.") + } } fn load_and_cache_npm_package_info( |