NativeScript / NativeScript/ios

Support ES modules

未关闭
#87 1 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

enhancement
主要语言
JavaScript
星标
150
派生
43
平均合并
3 天 10 小时
30 天内合并 PR
22

描述

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?

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从 ModuleInternal.mm 开始,跟踪现有的 commonjs 加载路径,并将其与提供的 ScriptCompiler::CompileModule 示例进行比较。研究 V8 模块加载和 commonjs 互操作应如何工作。完成的标准是 import 语句不再导致崩溃,并且运行时支持两种模块类型之间预期的交互。

由索引模型根据 Issue 内容生成。

评估

技术栈
ios, javascript
领域
mobile-dev
Issue 类型
功能
难度
5/5
预计耗时
一周以上
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。