Function import

Source
pub fn import(path: &str) -> Result<ModuleWrapper, Error>
Expand description

Imports a JS module into a new runtime

§Arguments

  • path - Path to the JS module to import

§Returns

A Result containing a handle to the imported module, or an error if something went wrong.

§Errors

Will return an error if the file cannot be found, execution fails, or the runtime cannot be started (usually due to extension issues)

§Example

let mut module = rustyscript::import("js/my_module.js").expect("Something went wrong!");