NativeScript / NativeScript/ios

Support ES modules

Open
#87 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
JavaScript
Stars
150
Forks
43
Avg merge
3d 10h
Merged PRs (30d)
22

Description

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?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in ModuleInternal.mm by tracing the existing commonjs loading path and compare it with the provided ScriptCompiler::CompileModule example. Investigate how V8 module loading and commonjs interoperation should work. Done means import statements no longer crash and the runtime supports the intended interaction between both module types.

Written by the indexing model from the issue text.

Assessment

Tech stack
ios, javascript
Domain
mobile-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.