mini-v8 icon indicating copy to clipboard operation
mini-v8 copied to clipboard

create bindings for isolates

Open tusharmath opened this issue 1 year ago • 2 comments

Hey! Thanks for this amazing library!

There are a few use cases where we are using mini-v8 and have reached a dead end when it comes to using isolates. mini-v8 doesn't have support for it, and it's quite a useful feature, especially for us where we are embedding v8 into our Rust application. We need to fire and run js in multiple contexts, moreover we also need to integrate it with https://crates.io/crates/serde_v8

tusharmath avatar Jan 24 '24 18:01 tusharmath

Hi there. In what way do you mean using isolates? Each MiniV8 instance is backed by its own V8 isolate, and there's no problem with creating multiple MiniV8s side-by-side. Do you mean exposing the internal v8::Isolate in some way? I fear this would lead introduce many complications.

Instead of trying to match the interfaces of serde_v8 and mini-v8, I would recommend creating a serde layer specifically suited to mini-v8. This should only amount to a few hundred lines of code; I did something similar a while ago for my ducc library.

SkylerLipthay avatar Jan 24 '24 20:01 SkylerLipthay

@SkylerLipthay How would it perform if we create MiniV8 instance in hot code, in comparison just running a mini_v8::Function in that path? From what I could gather, we need to pass the script for each instance, which could take sometime to execute.

tusharmath avatar Jan 26 '24 07:01 tusharmath