MCPcopy Create free account
hub / github.com/buke/quickjs-go / SetModuleImport

Method SetModuleImport

runtime.go:922–939  ·  view source on GitHub ↗

SetModuleImport installs or clears the default quickjs-libc file/module loader. When disabled, import resolution fails closed unless another loader is installed.

(moduleImport bool)

Source from the content-addressed store, hash-verified

920// SetModuleImport installs or clears the default quickjs-libc file/module loader.
921// When disabled, import resolution fails closed unless another loader is installed.
922func (r *Runtime) SetModuleImport(moduleImport bool) {
923 if r == nil {
924 return
925 }
926 if !r.ensureOwnerAccess() {
927 return
928 }
929 r.mu.Lock()
930 defer r.mu.Unlock()
931 if r.closed.Load() || r.ref == nil {
932 return
933 }
934 if moduleImport {
935 C.JS_SetModuleLoaderFunc2(r.ref, (*C.JSModuleNormalizeFunc)(unsafe.Pointer(nil)), (*C.JSModuleLoaderFunc2)(C.js_module_loader), (*C.JSModuleCheckSupportedImportAttributes)(C.js_module_check_attributes), unsafe.Pointer(nil))
936 return
937 }
938 C.JS_SetModuleLoaderFunc2(r.ref, (*C.JSModuleNormalizeFunc)(unsafe.Pointer(nil)), nil, nil, unsafe.Pointer(nil))
939}
940
941// SetInterruptHandler sets a user interrupt handler using simplified approach.
942// This will override any timeout handler (expected behavior)

Calls 2

ensureOwnerAccessMethod · 0.95
LoadMethod · 0.80