From 31fb7ac45bc194fed0b5198a1647019b0f63e4e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Thu, 7 Mar 2024 00:49:08 +0100 Subject: [PATCH 1/6] fix(publish): allow to enable sloppy imports and node builtins with env var --- cli/args/mod.rs | 8 +++++++ tests/integration/publish_tests.rs | 34 ++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/cli/args/mod.rs b/cli/args/mod.rs index af681104ceb01b..0f80611275c900 100644 --- a/cli/args/mod.rs +++ b/cli/args/mod.rs @@ -101,6 +101,12 @@ pub fn npm_registry_url() -> &'static Url { &NPM_REGISTRY_DEFAULT_URL } +static JSR_SLOPPY_IMPORTS_AND_NODE_BUILTINS: Lazy = Lazy::new(|| { + std::env::var("JSR_SLOPPY_IMPORTS_AND_NODE_BUILTINS") + .ok() + .is_some() +}); + pub fn jsr_url() -> &'static Url { static JSR_URL: Lazy = Lazy::new(|| { let env_var_name = "JSR_URL"; @@ -1537,6 +1543,7 @@ impl CliOptions { .as_ref() .map(|c| c.has_unstable("bare-node-builtins")) .unwrap_or(false) + || *JSR_SLOPPY_IMPORTS_AND_NODE_BUILTINS } pub fn unstable_byonm(&self) -> bool { @@ -1559,6 +1566,7 @@ impl CliOptions { .as_ref() .map(|c| c.has_unstable("sloppy-imports")) .unwrap_or(false) + || *JSR_SLOPPY_IMPORTS_AND_NODE_BUILTINS } pub fn unstable_features(&self) -> Vec { diff --git a/tests/integration/publish_tests.rs b/tests/integration/publish_tests.rs index ec5345553452b4..877d36586aa951 100644 --- a/tests/integration/publish_tests.rs +++ b/tests/integration/publish_tests.rs @@ -250,6 +250,23 @@ itest!(bare_node_builtins { http_server: true, }); +itest!(bare_node_builtins_with_env_var { + args: "publish --token 'sadfasdf' --dry-run --unstable-bare-node-builtins", + output: "publish/bare_node_builtins.out", + cwd: Some("publish/bare_node_builtins"), + envs: env_vars_for_jsr_npm_tests() + .into_iter() + .chain( + vec![( + "JSR_SLOPPY_IMPORTS_AND_NODE_BUILTINS".to_string(), + "1".to_string() + )] + .into_iter() + ) + .collect(), + http_server: true, +}); + itest!(sloppy_imports { args: "publish --token 'sadfasdf' --dry-run --unstable-sloppy-imports", output: "publish/sloppy_imports.out", @@ -258,6 +275,23 @@ itest!(sloppy_imports { http_server: true, }); +itest!(sloppy_imports_with_env_var { + args: "publish --token 'sadfasdf' --dry-run", + output: "publish/sloppy_imports.out", + cwd: Some("publish/sloppy_imports"), + envs: env_vars_for_jsr_tests() + .into_iter() + .chain( + vec![( + "JSR_SLOPPY_IMPORTS_AND_NODE_BUILTINS".to_string(), + "1".to_string() + )] + .into_iter() + ) + .collect(), + http_server: true, +}); + itest!(jsr_jsonc { args: "publish --token 'sadfasdf'", cwd: Some("publish/jsr_jsonc"), From 1903620a5b3be629635c2f15c0ecbe1b56a3200e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Thu, 7 Mar 2024 01:25:48 +0100 Subject: [PATCH 2/6] disable warnings --- cli/args/mod.rs | 15 ++-- cli/main.rs | 2 +- cli/tools/jupyter/mod.rs | 2 +- cli/util/logger.rs | 89 +++++++++++-------- tests/integration/publish_tests.rs | 14 +-- .../bare_node_builtins_no_warnings.out | 9 ++ .../publish/sloppy_imports_no_warnings.out | 8 ++ 7 files changed, 87 insertions(+), 52 deletions(-) create mode 100644 tests/testdata/publish/bare_node_builtins_no_warnings.out create mode 100644 tests/testdata/publish/sloppy_imports_no_warnings.out diff --git a/cli/args/mod.rs b/cli/args/mod.rs index 0f80611275c900..b1a0807eceaa3e 100644 --- a/cli/args/mod.rs +++ b/cli/args/mod.rs @@ -101,11 +101,12 @@ pub fn npm_registry_url() -> &'static Url { &NPM_REGISTRY_DEFAULT_URL } -static JSR_SLOPPY_IMPORTS_AND_NODE_BUILTINS: Lazy = Lazy::new(|| { - std::env::var("JSR_SLOPPY_IMPORTS_AND_NODE_BUILTINS") - .ok() - .is_some() -}); +pub static JSR_ALLOW_SLOPPY_IMPORTS_AND_NODE_BUILTINS: Lazy = + Lazy::new(|| { + std::env::var("JSR_ALLOW_SLOPPY_IMPORTS_AND_NODE_BUILTINS") + .ok() + .is_some() + }); pub fn jsr_url() -> &'static Url { static JSR_URL: Lazy = Lazy::new(|| { @@ -1543,7 +1544,7 @@ impl CliOptions { .as_ref() .map(|c| c.has_unstable("bare-node-builtins")) .unwrap_or(false) - || *JSR_SLOPPY_IMPORTS_AND_NODE_BUILTINS + || *JSR_ALLOW_SLOPPY_IMPORTS_AND_NODE_BUILTINS } pub fn unstable_byonm(&self) -> bool { @@ -1566,7 +1567,7 @@ impl CliOptions { .as_ref() .map(|c| c.has_unstable("sloppy-imports")) .unwrap_or(false) - || *JSR_SLOPPY_IMPORTS_AND_NODE_BUILTINS + || *JSR_ALLOW_SLOPPY_IMPORTS_AND_NODE_BUILTINS } pub fn unstable_features(&self) -> Vec { diff --git a/cli/main.rs b/cli/main.rs index d4a6846a8ee151..f575202a4a116c 100644 --- a/cli/main.rs +++ b/cli/main.rs @@ -388,7 +388,7 @@ pub fn main() { init_v8_flags(&default_v8_flags, &flags.v8_flags, get_v8_flags_from_env()); deno_core::JsRuntime::init_platform(None); - util::logger::init(flags.log_level); + util::logger::init(flags.log_level, &flags.subcommand); run_subcommand(flags).await }; diff --git a/cli/tools/jupyter/mod.rs b/cli/tools/jupyter/mod.rs index cf1a44ea5cf2da..d99a68f819dcff 100644 --- a/cli/tools/jupyter/mod.rs +++ b/cli/tools/jupyter/mod.rs @@ -51,7 +51,7 @@ pub async fn kernel( // This env var might be set by notebook if std::env::var("DEBUG").is_ok() { - logger::init(Some(log::Level::Debug)); + logger::init(Some(log::Level::Debug), &flags.subcommand); } let factory = CliFactory::from_flags(flags).await?; diff --git a/cli/util/logger.rs b/cli/util/logger.rs index 3cd0cbe5d2c6cb..4f146557e254e5 100644 --- a/cli/util/logger.rs +++ b/cli/util/logger.rs @@ -2,6 +2,9 @@ use std::io::Write; +use crate::args::DenoSubcommand; +use crate::args::JSR_ALLOW_SLOPPY_IMPORTS_AND_NODE_BUILTINS; + struct CliLogger(env_logger::Logger); impl CliLogger { @@ -30,45 +33,59 @@ impl log::Log for CliLogger { } } -pub fn init(maybe_level: Option) { +pub fn init(maybe_level: Option, subcommand: &DenoSubcommand) { let log_level = maybe_level.unwrap_or(log::Level::Info); - let logger = env_logger::Builder::from_env( + let mut builder = env_logger::Builder::from_env( env_logger::Env::default() .default_filter_or(log_level.to_level_filter().to_string()), - ) - // https://github.com/denoland/deno/issues/6641 - .filter_module("rustyline", log::LevelFilter::Off) - // wgpu crates (gfx_backend), have a lot of useless INFO and WARN logs - .filter_module("wgpu", log::LevelFilter::Error) - .filter_module("gfx", log::LevelFilter::Error) - // used to make available the lsp_debug which is then filtered out at runtime - // in the cli logger - .filter_module("deno::lsp::performance", log::LevelFilter::Debug) - .filter_module("rustls", log::LevelFilter::Off) - .format(|buf, record| { - let mut target = record.target().to_string(); - if let Some(line_no) = record.line() { - target.push(':'); - target.push_str(&line_no.to_string()); - } - if record.level() <= log::Level::Info - || (record.target() == "deno::lsp::performance" - && record.level() == log::Level::Debug) - { - // Print ERROR, WARN, INFO and lsp_debug logs as they are - writeln!(buf, "{}", record.args()) - } else { - // Add prefix to DEBUG or TRACE logs - writeln!( - buf, - "{} RS - {} - {}", - record.level(), - target, - record.args() - ) - } - }) - .build(); + ); + + builder + // https://github.com/denoland/deno/issues/6641 + .filter_module("rustyline", log::LevelFilter::Off) + // wgpu crates (gfx_backend), have a lot of useless INFO and WARN logs + .filter_module("wgpu", log::LevelFilter::Error) + .filter_module("gfx", log::LevelFilter::Error) + // used to make available the lsp_debug which is then filtered out at runtime + // in the cli logger + .filter_module("deno::lsp::performance", log::LevelFilter::Debug) + .filter_module("rustls", log::LevelFilter::Off); + + // If we're in `deno publish` and proper env var is passed we need to filter + // out messages from `deno_graph` and from ... + if matches!(subcommand, DenoSubcommand::Publish(..)) + && *JSR_ALLOW_SLOPPY_IMPORTS_AND_NODE_BUILTINS + { + builder + .filter_module("deno_graph", log::LevelFilter::Off) + .filter_module("deno::resolver", log::LevelFilter::Off); + } + + let logger = builder + .format(|buf, record| { + let mut target = record.target().to_string(); + if let Some(line_no) = record.line() { + target.push(':'); + target.push_str(&line_no.to_string()); + } + if record.level() <= log::Level::Info + || (record.target() == "deno::lsp::performance" + && record.level() == log::Level::Debug) + { + // Print ERROR, WARN, INFO and lsp_debug logs as they are + writeln!(buf, "{}", record.args()) + } else { + // Add prefix to DEBUG or TRACE logs + writeln!( + buf, + "{} RS - {} - {}", + record.level(), + target, + record.args() + ) + } + }) + .build(); let cli_logger = CliLogger::new(logger); let max_level = cli_logger.filter(); diff --git a/tests/integration/publish_tests.rs b/tests/integration/publish_tests.rs index 877d36586aa951..5a89fd34a61433 100644 --- a/tests/integration/publish_tests.rs +++ b/tests/integration/publish_tests.rs @@ -250,15 +250,15 @@ itest!(bare_node_builtins { http_server: true, }); -itest!(bare_node_builtins_with_env_var { - args: "publish --token 'sadfasdf' --dry-run --unstable-bare-node-builtins", - output: "publish/bare_node_builtins.out", +itest!(silence_bare_node_builtins_warning { + args: "publish --token 'sadfasdf' --dry-run", + output: "publish/bare_node_builtins_no_warnings.out", cwd: Some("publish/bare_node_builtins"), envs: env_vars_for_jsr_npm_tests() .into_iter() .chain( vec![( - "JSR_SLOPPY_IMPORTS_AND_NODE_BUILTINS".to_string(), + "JSR_ALLOW_SLOPPY_IMPORTS_AND_NODE_BUILTINS".to_string(), "1".to_string() )] .into_iter() @@ -275,15 +275,15 @@ itest!(sloppy_imports { http_server: true, }); -itest!(sloppy_imports_with_env_var { +itest!(silence_sloppy_imports_warnings { args: "publish --token 'sadfasdf' --dry-run", - output: "publish/sloppy_imports.out", + output: "publish/sloppy_imports_no_warnings.out", cwd: Some("publish/sloppy_imports"), envs: env_vars_for_jsr_tests() .into_iter() .chain( vec![( - "JSR_SLOPPY_IMPORTS_AND_NODE_BUILTINS".to_string(), + "JSR_ALLOW_SLOPPY_IMPORTS_AND_NODE_BUILTINS".to_string(), "1".to_string() )] .into_iter() diff --git a/tests/testdata/publish/bare_node_builtins_no_warnings.out b/tests/testdata/publish/bare_node_builtins_no_warnings.out new file mode 100644 index 00000000000000..c45c357cec9759 --- /dev/null +++ b/tests/testdata/publish/bare_node_builtins_no_warnings.out @@ -0,0 +1,9 @@ +Download http://localhost:4545/npm/registry/@types/node +Download http://localhost:4545/npm/registry/@types/node/node-18.8.2.tgz +Check file:///[WILDCARD]/publish/bare_node_builtins/mod.ts +Checking for slow types in the public API... +Check file:///[WILDCARD]/publish/bare_node_builtins/mod.ts +Simulating publish of @foo/bar@1.0.0 with files: + file:///[WILDCARD]/publish/bare_node_builtins/deno.json (87B) + file:///[WILDCARD]/publish/bare_node_builtins/mod.ts (121B) +Warning Aborting due to --dry-run diff --git a/tests/testdata/publish/sloppy_imports_no_warnings.out b/tests/testdata/publish/sloppy_imports_no_warnings.out new file mode 100644 index 00000000000000..8659010b7cf123 --- /dev/null +++ b/tests/testdata/publish/sloppy_imports_no_warnings.out @@ -0,0 +1,8 @@ +Check file:///[WILDCARD]/publish/sloppy_imports/mod.ts +Checking for slow types in the public API... +Check file:///[WILDCARD]/publish/sloppy_imports/mod.ts +Simulating publish of @foo/bar@1.0.0 with files: + file:///[WILDCARD]/publish/sloppy_imports/b/index.ts (27B) + file:///[WILDCARD]/publish/sloppy_imports/deno.json (87B) + file:///[WILDCARD]/publish/sloppy_imports/mod.ts (35B) +Warning Aborting due to --dry-run From 8edcd36d2cfad82f9e460db33793e07ec0987264 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Thu, 7 Mar 2024 01:40:12 +0100 Subject: [PATCH 3/6] change env var --- cli/args/mod.rs | 13 ++--- cli/main.rs | 2 +- cli/resolver.rs | 30 ++++++---- cli/tools/jupyter/mod.rs | 2 +- cli/util/logger.rs | 89 ++++++++++++------------------ tests/integration/publish_tests.rs | 12 ++-- 6 files changed, 67 insertions(+), 81 deletions(-) diff --git a/cli/args/mod.rs b/cli/args/mod.rs index b1a0807eceaa3e..acdc9652631ea1 100644 --- a/cli/args/mod.rs +++ b/cli/args/mod.rs @@ -101,12 +101,11 @@ pub fn npm_registry_url() -> &'static Url { &NPM_REGISTRY_DEFAULT_URL } -pub static JSR_ALLOW_SLOPPY_IMPORTS_AND_NODE_BUILTINS: Lazy = - Lazy::new(|| { - std::env::var("JSR_ALLOW_SLOPPY_IMPORTS_AND_NODE_BUILTINS") - .ok() - .is_some() - }); +pub static DENO_DISABLE_PEDANTIC_NODE_WARNINGS: Lazy = Lazy::new(|| { + std::env::var("DENO_DISABLE_PEDANTIC_NODE_WARNINGS") + .ok() + .is_some() +}); pub fn jsr_url() -> &'static Url { static JSR_URL: Lazy = Lazy::new(|| { @@ -1544,7 +1543,6 @@ impl CliOptions { .as_ref() .map(|c| c.has_unstable("bare-node-builtins")) .unwrap_or(false) - || *JSR_ALLOW_SLOPPY_IMPORTS_AND_NODE_BUILTINS } pub fn unstable_byonm(&self) -> bool { @@ -1567,7 +1565,6 @@ impl CliOptions { .as_ref() .map(|c| c.has_unstable("sloppy-imports")) .unwrap_or(false) - || *JSR_ALLOW_SLOPPY_IMPORTS_AND_NODE_BUILTINS } pub fn unstable_features(&self) -> Vec { diff --git a/cli/main.rs b/cli/main.rs index f575202a4a116c..d4a6846a8ee151 100644 --- a/cli/main.rs +++ b/cli/main.rs @@ -388,7 +388,7 @@ pub fn main() { init_v8_flags(&default_v8_flags, &flags.v8_flags, get_v8_flags_from_env()); deno_core::JsRuntime::init_platform(None); - util::logger::init(flags.log_level, &flags.subcommand); + util::logger::init(flags.log_level); run_subcommand(flags).await }; diff --git a/cli/resolver.rs b/cli/resolver.rs index e1a2145d3b040d..8043e1ede18e3e 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( diff --git a/cli/tools/jupyter/mod.rs b/cli/tools/jupyter/mod.rs index d99a68f819dcff..cf1a44ea5cf2da 100644 --- a/cli/tools/jupyter/mod.rs +++ b/cli/tools/jupyter/mod.rs @@ -51,7 +51,7 @@ pub async fn kernel( // This env var might be set by notebook if std::env::var("DEBUG").is_ok() { - logger::init(Some(log::Level::Debug), &flags.subcommand); + logger::init(Some(log::Level::Debug)); } let factory = CliFactory::from_flags(flags).await?; diff --git a/cli/util/logger.rs b/cli/util/logger.rs index 4f146557e254e5..3cd0cbe5d2c6cb 100644 --- a/cli/util/logger.rs +++ b/cli/util/logger.rs @@ -2,9 +2,6 @@ use std::io::Write; -use crate::args::DenoSubcommand; -use crate::args::JSR_ALLOW_SLOPPY_IMPORTS_AND_NODE_BUILTINS; - struct CliLogger(env_logger::Logger); impl CliLogger { @@ -33,59 +30,45 @@ impl log::Log for CliLogger { } } -pub fn init(maybe_level: Option, subcommand: &DenoSubcommand) { +pub fn init(maybe_level: Option) { let log_level = maybe_level.unwrap_or(log::Level::Info); - let mut builder = env_logger::Builder::from_env( + let logger = env_logger::Builder::from_env( env_logger::Env::default() .default_filter_or(log_level.to_level_filter().to_string()), - ); - - builder - // https://github.com/denoland/deno/issues/6641 - .filter_module("rustyline", log::LevelFilter::Off) - // wgpu crates (gfx_backend), have a lot of useless INFO and WARN logs - .filter_module("wgpu", log::LevelFilter::Error) - .filter_module("gfx", log::LevelFilter::Error) - // used to make available the lsp_debug which is then filtered out at runtime - // in the cli logger - .filter_module("deno::lsp::performance", log::LevelFilter::Debug) - .filter_module("rustls", log::LevelFilter::Off); - - // If we're in `deno publish` and proper env var is passed we need to filter - // out messages from `deno_graph` and from ... - if matches!(subcommand, DenoSubcommand::Publish(..)) - && *JSR_ALLOW_SLOPPY_IMPORTS_AND_NODE_BUILTINS - { - builder - .filter_module("deno_graph", log::LevelFilter::Off) - .filter_module("deno::resolver", log::LevelFilter::Off); - } - - let logger = builder - .format(|buf, record| { - let mut target = record.target().to_string(); - if let Some(line_no) = record.line() { - target.push(':'); - target.push_str(&line_no.to_string()); - } - if record.level() <= log::Level::Info - || (record.target() == "deno::lsp::performance" - && record.level() == log::Level::Debug) - { - // Print ERROR, WARN, INFO and lsp_debug logs as they are - writeln!(buf, "{}", record.args()) - } else { - // Add prefix to DEBUG or TRACE logs - writeln!( - buf, - "{} RS - {} - {}", - record.level(), - target, - record.args() - ) - } - }) - .build(); + ) + // https://github.com/denoland/deno/issues/6641 + .filter_module("rustyline", log::LevelFilter::Off) + // wgpu crates (gfx_backend), have a lot of useless INFO and WARN logs + .filter_module("wgpu", log::LevelFilter::Error) + .filter_module("gfx", log::LevelFilter::Error) + // used to make available the lsp_debug which is then filtered out at runtime + // in the cli logger + .filter_module("deno::lsp::performance", log::LevelFilter::Debug) + .filter_module("rustls", log::LevelFilter::Off) + .format(|buf, record| { + let mut target = record.target().to_string(); + if let Some(line_no) = record.line() { + target.push(':'); + target.push_str(&line_no.to_string()); + } + if record.level() <= log::Level::Info + || (record.target() == "deno::lsp::performance" + && record.level() == log::Level::Debug) + { + // Print ERROR, WARN, INFO and lsp_debug logs as they are + writeln!(buf, "{}", record.args()) + } else { + // Add prefix to DEBUG or TRACE logs + writeln!( + buf, + "{} RS - {} - {}", + record.level(), + target, + record.args() + ) + } + }) + .build(); let cli_logger = CliLogger::new(logger); let max_level = cli_logger.filter(); diff --git a/tests/integration/publish_tests.rs b/tests/integration/publish_tests.rs index 5a89fd34a61433..ce93ccda3ff9d1 100644 --- a/tests/integration/publish_tests.rs +++ b/tests/integration/publish_tests.rs @@ -250,15 +250,15 @@ itest!(bare_node_builtins { http_server: true, }); -itest!(silence_bare_node_builtins_warning { - args: "publish --token 'sadfasdf' --dry-run", +itest!(bare_node_builtins_warning_no_warnings { + args: "publish --token 'sadfasdf' --dry-run --unstable-bare-node-builtins", output: "publish/bare_node_builtins_no_warnings.out", cwd: Some("publish/bare_node_builtins"), envs: env_vars_for_jsr_npm_tests() .into_iter() .chain( vec![( - "JSR_ALLOW_SLOPPY_IMPORTS_AND_NODE_BUILTINS".to_string(), + "DENO_DISABLE_PEDANTIC_NODE_WARNINGS".to_string(), "1".to_string() )] .into_iter() @@ -275,15 +275,15 @@ itest!(sloppy_imports { http_server: true, }); -itest!(silence_sloppy_imports_warnings { - args: "publish --token 'sadfasdf' --dry-run", +itest!(sloppy_imports_no_warnings { + args: "publish --token 'sadfasdf' --dry-run --unstable-sloppy-imports", output: "publish/sloppy_imports_no_warnings.out", cwd: Some("publish/sloppy_imports"), envs: env_vars_for_jsr_tests() .into_iter() .chain( vec![( - "JSR_ALLOW_SLOPPY_IMPORTS_AND_NODE_BUILTINS".to_string(), + "DENO_DISABLE_PEDANTIC_NODE_WARNINGS".to_string(), "1".to_string() )] .into_iter() From d04804c945fba4372836290d5f5b1da1a7c4464b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Thu, 7 Mar 2024 13:47:28 +0100 Subject: [PATCH 4/6] disable another use with env var --- cli/graph_util.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cli/graph_util.rs b/cli/graph_util.rs index f1aa4432889323..24a14412b204dc 100644 --- a/cli/graph_util.rs +++ b/cli/graph_util.rs @@ -680,7 +680,9 @@ pub fn error_for_any_npm_specifier( pub fn enhanced_resolution_error_message(error: &ResolutionError) -> String { let mut message = format!("{error}"); - if let Some(specifier) = get_resolution_error_bare_node_specifier(error) { + if let Some(specifier) = get_resolution_error_bare_node_specifier(error) + && !*DENO_DISABLE_PEDANTIC_NODE_WARNINGS + { message.push_str(&format!( "\nIf you want to use a built-in Node module, add a \"node:\" prefix (ex. \"node:{specifier}\")." )); From 4cbf0251e01b1a3c6124def85c2bee4a2e0d27e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Thu, 7 Mar 2024 13:54:33 +0100 Subject: [PATCH 5/6] import --- cli/graph_util.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/cli/graph_util.rs b/cli/graph_util.rs index 24a14412b204dc..1049f02b5795c2 100644 --- a/cli/graph_util.rs +++ b/cli/graph_util.rs @@ -4,6 +4,7 @@ use crate::args::jsr_url; use crate::args::CliOptions; use crate::args::Lockfile; use crate::args::TsTypeLib; +use crate::args::DENO_DISABLE_PEDANTIC_NODE_WARNINGS; use crate::cache; use crate::cache::GlobalHttpCache; use crate::cache::ModuleInfoCache; From bdec167c2d5c1deea7df9ff514fd0eddbb22558d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Thu, 7 Mar 2024 13:59:07 +0100 Subject: [PATCH 6/6] lint --- cli/graph_util.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cli/graph_util.rs b/cli/graph_util.rs index 1049f02b5795c2..b84cb3bb649ece 100644 --- a/cli/graph_util.rs +++ b/cli/graph_util.rs @@ -681,12 +681,12 @@ pub fn error_for_any_npm_specifier( pub fn enhanced_resolution_error_message(error: &ResolutionError) -> String { let mut message = format!("{error}"); - if let Some(specifier) = get_resolution_error_bare_node_specifier(error) - && !*DENO_DISABLE_PEDANTIC_NODE_WARNINGS - { - message.push_str(&format!( + if let Some(specifier) = get_resolution_error_bare_node_specifier(error) { + if !*DENO_DISABLE_PEDANTIC_NODE_WARNINGS { + message.push_str(&format!( "\nIf you want to use a built-in Node module, add a \"node:\" prefix (ex. \"node:{specifier}\")." )); + } } message