@@ -691,7 +691,11 @@ pub fn Env(comptime State: type, comptime WebApis: type) type {
691691
692692 // compile and eval a JS module
693693 // It doesn't wait for callbacks execution
694- pub fn module (self : * JsContext , src : []const u8 , url : []const u8 ) ! void {
694+ pub fn module (self : * JsContext , src : []const u8 , url : []const u8 , cacheable : bool ) ! void {
695+ if (! cacheable ) {
696+ return self .moduleNoCache (src , url );
697+ }
698+
695699 const arena = self .context_arena ;
696700
697701 const gop = try self .module_cache .getOrPut (arena , url );
@@ -718,6 +722,16 @@ pub fn Env(comptime State: type, comptime WebApis: type) type {
718722 _ = try m .evaluate (v8_context );
719723 }
720724
725+ fn moduleNoCache (self : * JsContext , src : []const u8 , url : []const u8 ) ! void {
726+ const m = try compileModule (self .isolate , src , url );
727+ const v8_context = self .v8_context ;
728+ if (try m .instantiate (v8_context , resolveModuleCallback ) == false ) {
729+ return error .ModuleInstantiationError ;
730+ }
731+
732+ _ = try m .evaluate (v8_context );
733+ }
734+
721735 // Wrap a v8.Exception
722736 fn createException (self : * const JsContext , e : v8.Value ) Exception {
723737 return .{
0 commit comments