summaryrefslogtreecommitdiff
path: root/runtime/shared.rs
diff options
context:
space:
mode:
authorBartek Iwańczuk <biwanczuk@gmail.com>2024-08-19 21:36:35 +0100
committerGitHub <noreply@github.com>2024-08-19 22:36:35 +0200
commitb5051e25c219c188f17d499ee4e101a64eb62e37 (patch)
tree88c6ab12aefd491d52e638c6e5043728412bca9b /runtime/shared.rs
parentbf510544ef26b89d4c2ae935893eaf62995ed903 (diff)
feat: Deprecate "import assertions" with a warning (#24743)
This commit deprecates "import assertions" proposal that has been replaced with "import attributes". Any time an import assertion is encountered a warning will be printed to the terminal. This warning will be printed for both local and remote files (ie. user code and dependencies). Import assertions support will be removed in Deno 2.
Diffstat (limited to 'runtime/shared.rs')
-rw-r--r--runtime/shared.rs23
1 files changed, 23 insertions, 0 deletions
diff --git a/runtime/shared.rs b/runtime/shared.rs
index 1b2136c63..c52521690 100644
--- a/runtime/shared.rs
+++ b/runtime/shared.rs
@@ -116,3 +116,26 @@ pub fn maybe_transpile_source(
Ok((source_text.into(), maybe_source_map))
}
+
+pub fn import_assertion_callback(
+ args: deno_core::ImportAssertionsSupportCustomCallbackArgs,
+) {
+ let mut msg = deno_terminal::colors::yellow("⚠️ Import assertions are deprecated. Use `with` keyword, instead of 'assert' keyword.").to_string();
+ if let Some(specifier) = args.maybe_specifier {
+ if let Some(source_line) = args.maybe_source_line {
+ msg.push_str("\n\n");
+ msg.push_str(&source_line);
+ msg.push_str("\n\n");
+ }
+ msg.push_str(&format!(
+ " at {}:{}:{}\n",
+ specifier,
+ args.maybe_line_number.unwrap(),
+ args.column_number
+ ));
+ #[allow(clippy::print_stderr)]
+ {
+ eprintln!("{}", msg);
+ }
+ }
+}