caoccao/Javet

Add createV8Module() to V8Runtime

Closed this issue · 0 comments

Background

A synthetic module in V8 is a module that is created by the V8 JavaScript engine at runtime. Synthetic modules are typically used to implement new features in JavaScript, such as the module proposal for JSON imports.

Synthetic modules have a number of advantages over traditional JavaScript modules. First, they can be created and evaluated at runtime, which allows for more flexibility and dynamism. Second, synthetic modules can be isolated from the rest of the code, which makes them more secure.

Synthetic modules are implemented in V8 using a special type of module called a "Module Record". Module Records are responsible for managing the exports and imports of a module. When a synthetic module is evaluated, V8 creates a new Module Record for the module. This Module Record is then used to resolve imports and exports.

Objectives

  • Add isSourceTextModule(), isSyntheticModule() to V8Module.
  • Add createV8Module(String name, IV8ValueObject iV8ValueObject) to V8Runtime.
  • Add corresponding unit test cases.