Modules are designed (in the JavaScript spec) to only have their top-level code run once. To "re-use" a cached module, the expectation is that other modules would use imports to access the exports of that module. In particular, in your code snippet, you'd return the already-evaluated module from the ResolveCallback passed to the module that wishes to import from it.
If what you want to do is compile some code and run it multiple times, a v8::Script is probably want you want instead. On Tue, Feb 12, 2019 at 5:11 PM Jane Chen <jxche...@gmail.com> wrote: > Embedding v8 6.7. > > I found the following test in test-modules.cc: > > CHECK(module->Evaluate(env.local()) > .ToLocalChecked() > ->StrictEquals(v8_str("gaga"))); > CHECK_EQ(Module::kEvaluated, module->GetStatus()); > CHECK(module->Evaluate(env.local()).ToLocalChecked()->IsUndefined()); > > and it is consistent with what I'm seeing. Basically, evaluating an > evaluated module returns undefined. I don't get the rational for this > behavior. Once a module is evaluated, it is no good for evaluation? Then > how am I supposed to re-use a cached module? Re-instantiating it doesn't > seem to help. > > -- > -- > v8-users mailing list > v8-users@googlegroups.com > http://groups.google.com/group/v8-users > --- > You received this message because you are subscribed to the Google Groups > "v8-users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to v8-users+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups "v8-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.