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/worker.rs | |
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/worker.rs')
-rw-r--r-- | runtime/worker.rs | 15 |
1 files changed, 15 insertions, 0 deletions
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() }); |