Skip to content

Support ES modules #87

Open
Open
@rigor789

Description

@rigor789

The runtime currently handles commonjs modules - and if an import statement is encountered the application will crash.

The implementation is currently in ModuleInternal.mm

It would be awesome if es modules were supported, since v8 already supports them - we are just missing the implementation for loading them (same-ish logic as for commonjs)

A reduced example for supporting es modules: https://stackoverflow.com/a/52031275/2270725

The gist of it is - we have to call ScriptCompiler::CompileModule on the source

Local<Module> module;
if (!ScriptCompiler::CompileModule(isolate, &source).ToLocal(&module)) {
  // if you have a v8::TryCatch, you should check it here.
  return;
}

Unresolved questions:

  • Can the runtime support both types and interop between them?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions