summaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
Diffstat (limited to 'runtime')
-rw-r--r--runtime/shared.rs23
-rw-r--r--runtime/web_worker.rs8
-rw-r--r--runtime/worker.rs20
3 files changed, 40 insertions, 11 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);
+ }
+ }
+}
diff --git a/runtime/web_worker.rs b/runtime/web_worker.rs
index ed1e19c9e..3e95045db 100644
--- a/runtime/web_worker.rs
+++ b/runtime/web_worker.rs
@@ -538,6 +538,13 @@ impl WebWorker {
options.bootstrap.enable_op_summary_metrics,
options.strace_ops,
);
+ let import_assertions_support = if options.bootstrap.future {
+ deno_core::ImportAssertionsSupport::Error
+ } else {
+ deno_core::ImportAssertionsSupport::CustomCallback(Box::new(
+ crate::shared::import_assertion_callback,
+ ))
+ };
let mut js_runtime = JsRuntime::new(RuntimeOptions {
module_loader: Some(options.module_loader.clone()),
@@ -558,6 +565,7 @@ impl WebWorker {
validate_import_attributes_cb: Some(Box::new(
validate_import_attributes_callback,
)),
+ import_assertions_support,
..Default::default()
});
diff --git a/runtime/worker.rs b/runtime/worker.rs
index 696786b56..c1c918d08 100644
--- a/runtime/worker.rs
+++ b/runtime/worker.rs
@@ -476,6 +476,14 @@ impl MainWorker {
}
});
+ let import_assertions_support = if options.bootstrap.future {
+ deno_core::ImportAssertionsSupport::Error
+ } else {
+ deno_core::ImportAssertionsSupport::CustomCallback(Box::new(
+ crate::shared::import_assertion_callback,
+ ))
+ };
+
let mut js_runtime = JsRuntime::new(RuntimeOptions {
module_loader: Some(options.module_loader.clone()),
startup_snapshot: options.startup_snapshot,
@@ -501,6 +509,7 @@ impl MainWorker {
validate_import_attributes_cb: Some(Box::new(
validate_import_attributes_callback,
)),
+ import_assertions_support,
eval_context_code_cache_cbs: options.v8_code_cache.map(|cache| {
let cache_clone = cache.clone();
(
@@ -544,17 +553,6 @@ impl MainWorker {
if let Some(op_summary_metrics) = op_summary_metrics {
js_runtime.op_state().borrow_mut().put(op_summary_metrics);
}
- extern "C" fn message_handler(
- _msg: v8::Local<v8::Message>,
- _exception: v8::Local<v8::Value>,
- ) {
- // TODO(@littledivy): Propogate message to users.
- }
-
- // Register message listener
- js_runtime
- .v8_isolate()
- .add_message_listener(message_handler);
if let Some(server) = options.maybe_inspector_server.clone() {
server.register_inspector(