Skip to main content

JS_SetModuleLoaderFunc

Function JS_SetModuleLoaderFunc 

Source
#[unsafe(no_mangle)]
pub unsafe extern "C" fn JS_SetModuleLoaderFunc( rt: *mut JsRuntime, module_normalize: ModuleNormalizeFunc, module_loader: ModuleLoaderFunc, opaque: *mut c_void, )
Expand description

JS_SetModuleLoaderFunc: install how a specifier becomes a module.

The pair is recorded on the runtime. The engine reaches them through its own ModuleLoader, which quickjs-cli installs; a host that sets these and has no loader of its own gets a TypeError at the first import, which is a clearer failure than a silently unavailable module.

§Safety

rt must be a live runtime; the function pointers must match the header’s signatures.