title: How can I include another js file file in today's v8?
body: <p>I find an old anwser and later updates <a href="https://stackoverflow.com/questions/1149340/how-do-you-include-another-js-file-in-googles-v8">here</a>, but it is hard for me to adapt this code to the latest(2020) V8 version.</p>
  <p>There are many difficulties that I encounter:</p>
  <ol>
  <li><code>String::New</code> is removed and now a <code>String::NewFromUtf8Literal</code> needs an <code>Isolate* isolate</code> which I don't know how to pass to function <code>Include</code>, should I just add this before <code>const Arguments&amp; args</code>?</li>
  <li><code>Script::Compile</code> takes a <code>Context</code> object as paramater now</li>
  <li>And I don't know where to put the last two line codes
  <pre><code>Handle&lt;ObjectTemplate&gt; global = ObjectTemplate::New();
  global-&gt;Set(String::New(&quot;include&quot;), FunctionTemplate::New(Include));
  </code></pre>
  </li>
  </ol>
  <p>-- UPDATE --</p>
  <p>After some work, I have my code like the <a href="https://paste.ubuntu.com/p/mmh4VvNpNj/" rel="nofollow noreferrer">this</a>.</p>
  <p>However, it still won't compile because of there errors:</p>
  <ol>
  <li><p>Seems that I can't get a <code>Local</code> from a <code>Persistent</code>, even I have used <a href="https://stackoverflow.com/questions/22646546/how-to-store-persistent-handles-in-v8/22648552#22648552">danijar's strategy</a>. Maybe it is because I have not used the constructor, but I don't think I can construct a Persist here inside this function scope.</p>
  <pre><code>samples/import.cc:74:103: Error：cannot convert ‘v8::Local&lt;v8::Context&gt;’ to ‘v8::Context*’
     74 |     global_context = v8::Persistent&lt;v8::Context, CopyablePersistentTraits&lt;v8::Context&gt;&gt;::New(isolate, local_context);
        |                                                                                                       ^~~~~~~~~~~~~
        |                                                                                                       |
        |                                                                                                       v8::Local&lt;v8::Context&gt;
  </code></pre>
  </li>
  <li><p>There are some errors with <code>String::NewFromUtf8Literal</code> here</p>
  <pre><code>samples/import.cc:34:110: Error：‘static v8::Local&lt;v8::String&gt; v8::String::NewFromUtf8Literal(v8::Isolate*, const char*, v8::NewStringType, int)’ is private within this context
     34 |   Handle&lt;String&gt; source = String::NewFromUtf8Literal(args.GetIsolate(), buff, v8::NewStringType::kNormal, len);
        |   
  </code></pre>
  </li>
  </ol>