From d192cc264020a8eeeafbdde4f06bb9b1cae9a5d2 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Thu, 7 Dec 2023 22:35:53 -0500 Subject: fix: add more warnings when using sloppy imports (#21503) One warning for when using it with `deno compile` and another when using it with `deno run`. --- cli/tools/compile.rs | 12 ++++++++++++ cli/tools/run/mod.rs | 7 +++++++ 2 files changed, 19 insertions(+) (limited to 'cli/tools') diff --git a/cli/tools/compile.rs b/cli/tools/compile.rs index b36ee94bd..b8007f7fd 100644 --- a/cli/tools/compile.rs +++ b/cli/tools/compile.rs @@ -37,6 +37,18 @@ pub async fn compile( vec }; + // this is not supported, so show a warning about it, but don't error in order + // to allow someone to still run `deno compile` when this is in a deno.json + if cli_options.unstable_sloppy_imports() { + log::warn!( + concat!( + "{} Sloppy imports are not supported in deno compile. ", + "The compiled executable may encouter runtime errors.", + ), + crate::colors::yellow("Warning"), + ); + } + let output_path = resolve_compile_executable_output_path( &compile_flags, cli_options.initial_cwd(), diff --git a/cli/tools/run/mod.rs b/cli/tools/run/mod.rs index 321f94fc6..f4604e248 100644 --- a/cli/tools/run/mod.rs +++ b/cli/tools/run/mod.rs @@ -45,6 +45,13 @@ To grant permissions, set them before the script argument. For example: let http_client = factory.http_client(); let cli_options = factory.cli_options(); + if cli_options.unstable_sloppy_imports() { + log::warn!( + "{} Sloppy imports are not recommended and have a negative impact on performance.", + crate::colors::yellow("Warning"), + ); + } + // Run a background task that checks for available upgrades or output // if an earlier run of this background task found a new version of Deno. #[cfg(feature = "upgrade")] -- cgit v1.2.3