Skip to content

Commit 3a3b5e2

Browse files
committed
fix(guest): adapt Resolver/Loader to rquickjs 0.12
rquickjs 0.12 adds an import-attributes parameter to the module loader traits: `Resolver::resolve` and `Loader::load` now take a trailing `Option<ImportAttributes>` (for `import ... with { type }`). Update StubModuleLoader's impls to match the new signatures; the stub ignores attributes since it accepts any module for syntax validation. Signed-off-by: Simon Davies <simongdavies@users.noreply.github.com>
1 parent ca40b4d commit 3a3b5e2

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

src/code-validator/guest/runtime/src/validator.rs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ use alloc::vec::Vec;
3232
use core::cell::RefCell;
3333
use core::sync::atomic::{AtomicU64, Ordering};
3434
use hashbrown::HashMap;
35-
use rquickjs::loader::{Loader, Resolver};
35+
use rquickjs::loader::{ImportAttributes, Loader, Resolver};
3636
use rquickjs::{Context, Ctx, Module, Result as QjsResult, Runtime};
3737
use serde::{Deserialize, Serialize};
3838
use sha2::{Digest, Sha256};
@@ -62,14 +62,25 @@ struct StubModuleLoader {
6262
}
6363

6464
impl Resolver for StubModuleLoader {
65-
fn resolve(&mut self, _ctx: &Ctx<'_>, _base: &str, name: &str) -> QjsResult<String> {
65+
fn resolve(
66+
&mut self,
67+
_ctx: &Ctx<'_>,
68+
_base: &str,
69+
name: &str,
70+
_attributes: Option<ImportAttributes<'_>>,
71+
) -> QjsResult<String> {
6672
// Accept any module name for syntax validation
6773
Ok(name.to_string())
6874
}
6975
}
7076

7177
impl Loader for StubModuleLoader {
72-
fn load<'js>(&mut self, ctx: &Ctx<'js>, name: &str) -> QjsResult<Module<'js>> {
78+
fn load<'js>(
79+
&mut self,
80+
ctx: &Ctx<'js>,
81+
name: &str,
82+
_attributes: Option<ImportAttributes<'js>>,
83+
) -> QjsResult<Module<'js>> {
7384
// Track that we saw this module
7485
self.seen.borrow_mut().insert(name.to_string(), ());
7586
// Provide a minimal stub module

0 commit comments

Comments
 (0)