diff options
| author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2023-12-28 20:37:10 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-12-28 20:37:10 +0100 |
| commit | 576b20aa005c233b95afe6e3692a899ae8f755f2 (patch) | |
| tree | 584a0eb42fb785eccfab6a590c1b4b84b77ef51d /runtime | |
| parent | f85d65e066302ad7357321ec9e2940c2346d2263 (diff) | |
fix: allow npm: specifiers in import.meta.resolve (#21716)
Closes https://github.com/denoland/deno/issues/21298.
"npm:" specifiers are matched against import map entries
and if no match is found they are passed through.
Diffstat (limited to 'runtime')
| -rw-r--r-- | runtime/web_worker.rs | 4 | ||||
| -rw-r--r-- | runtime/worker.rs | 15 |
2 files changed, 19 insertions, 0 deletions
diff --git a/runtime/web_worker.rs b/runtime/web_worker.rs index 41e6ca4fe..308c294ef 100644 --- a/runtime/web_worker.rs +++ b/runtime/web_worker.rs @@ -5,6 +5,7 @@ use crate::ops; use crate::permissions::PermissionsContainer; use crate::shared::runtime; use crate::tokio_util::create_and_run_current_thread; +use crate::worker::import_meta_resolve_callback; use crate::worker::FormatJsErrorFn; use crate::BootstrapOptions; use deno_broadcast_channel::InMemoryBroadcastChannel; @@ -536,6 +537,9 @@ impl WebWorker { inspector: options.maybe_inspector_server.is_some(), feature_checker: Some(options.feature_checker.clone()), op_metrics_factory_fn, + import_meta_resolve_callback: Some(Box::new( + import_meta_resolve_callback, + )), ..Default::default() }); diff --git a/runtime/worker.rs b/runtime/worker.rs index 237ebfe13..f48f81fe7 100644 --- a/runtime/worker.rs +++ b/runtime/worker.rs @@ -50,6 +50,18 @@ use crate::BootstrapOptions; pub type FormatJsErrorFn = dyn Fn(&JsError) -> String + Sync + Send; +pub fn import_meta_resolve_callback( + loader: &dyn deno_core::ModuleLoader, + specifier: String, + referrer: String, +) -> Result<ModuleSpecifier, AnyError> { + loader.resolve( + &specifier, + &referrer, + deno_core::ResolutionKind::DynamicImport, + ) +} + #[derive(Clone, Default)] pub struct ExitCode(Arc<AtomicI32>); @@ -447,6 +459,9 @@ impl MainWorker { wait_for_inspector_disconnect_callback: Some( wait_for_inspector_disconnect_callback, ), + import_meta_resolve_callback: Some(Box::new( + import_meta_resolve_callback, + )), ..Default::default() }); |
