boopus_the_snootusB
Denoβ€’3y agoβ€’
10 replies
boopus_the_snootus

Getting exports from an evaluated module with get_module_namespace always results in null values

Trying to get module exports like the example here

The module is loaded with load_main_module, I call mod_evaluate on the ID returned, then do the below:

But the value returned is always undefined

Js:
    export function test() { return 2;}


Rust:
      let module_namespace = self.deno_runtime.get_module_namespace(module_id)?;
      let mut scope = self.deno_runtime.handle_scope();
      let module_namespace = v8::Local::<v8::Object>::new(&mut scope, module_namespace);

      let key = v8::String::new(&mut scope, "test").unwrap();
      let value = module_namespace.get(&mut scope, key.into()).unwrap();

      println!("{}", value.is_undefined()); // true
GitHub
Allows users to access the namespace object of a module.
Example - Extracting the default export binding of a JavaScript module using deno_core
...
let module_namespace = runtime.get_module_namespa...
feat(core): Adds a new method get_module_namespace to access the na...
Was this page helpful?