Skip to content
Discussion options

You must be logged in to vote

I think the confusing part is that there are two different namespaces involved here.

A JavaScript module has its own module environment / module namespace for its exports. So from JS you can do:

import * as fs from "/advancedfx/fs.mjs";
fs.readDir(".");

and those exports are namespaced under fs.

But Class::from_data(...) is not looking up an exported module binding. It needs the native class registration/prototype from Boa’s registered-class map for the current realm. That registration is realm-level, not module-local.

That is why the previous fix works:

fs::boa_register(realm.clone(), context)?;
Ok(fs::boa_module(realm, context)?)

but it also makes the class visible through the realm/glo…

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