0

I am new google to google v8.

I modified v8 hello world app.

const char* testJS = R"(
   var assert = require("assert");
   1 + 2;
)";
v8::Local<v8::Script> script = v8::Script::Compile(context, testJS).ToLocalChecked();

https://chromium.googlesource.com/v8/v8/+/branch-heads/5.8/samples/hello-world.cc

but got exception when running

Uncaught ReferenceError: require is not defined

So my question is, how could I 1) use 'require' in google v8 2) Make a custom common javascript class could be used as 'require(xyz)'

is they are related to v8::StartupData, but I don't know how to setup them correctly. Any advice would be appreciated.

thanks

  • check this, https://stackoverflow.com/questions/1149340/how-do-you-include-another-js-file-in-googles-v8 – Casper Nov 27 '17 at 01:00

1 Answers1

0

The function require() is not a part of ECMAScript. If you need it, you have to implement it by yourself.