Loading
Commits on Source 17
-
cznic authored
This commit exposes the QuickJS module loader functionality (JS_SetModuleLoaderFunc2) via an idiomatic Go API, allowing users to define custom resolution and loading logic for ES6 modules. Changes: - Add `ModuleLoaderFunc` and `ModuleNormalizeFunc` types. - Add `VM.SetModuleLoader()` to configure the custom hooks. - Implement a thread-safe internal registry (`vms` map) to route incoming C callbacks back to the correct Go `*VM` instance via the `opaque` pointer. - Add C-to-Go bridge functions (`goModuleLoader`, `goModuleNormalize`) to handle string conversion, QuickJS internal memory allocation (`js_malloc`), and proper pointer extraction. - Add `throwReferenceError` helper to correctly format and throw JavaScript ReferenceErrors when module resolution fails. - Add unit tests for successful module evaluation and error handling.
-
cznic authored
-
cznic authored
-
cznic authored
-
cznic authored
-
cznic authored
-
cznic authored
-
cznic authored
-
cznic authored
-
cznic authored
-
cznic authored
-
cznic authored
-
cznic authored
-
cznic authored
-
cznic authored
-
cznic authored
-
cznic authored