Skip to content
Discussion options

You must be logged in to vote

from_data does not register the native class. It only creates an object using the prototype from the registered-class map, and this error is raised when that class is missing from the current realm.

With #[boa_module], the generated boa_module(...) exports the constructors from the synthetic module. For Class::from_data(...), you also need to register the classes, either through the generated boa_register(...) helper or manually.

For example, change your wrapper to return a JsResult<Module> and register before returning the module:

pub fn module(realm: Option<Realm>, context: &mut Context) -> JsResult<Module> {
    fs::boa_register(realm.clone(), context)?;
    Ok(fs::boa_module(realm, co…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@dtugend
Comment options

Answer selected by dtugend
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants