将使用JS创建的模块快速转换为C,并将其用作内置模块。

huangapple go评论52阅读模式
英文:

QuickJS Translate a Module Created with JS to C and Use it as a Builtin Module

问题

我阅读了这篇文章:在QuickJS引擎中使用C编写本地模块

但我可以使用JS更快更容易地编写模块。创建模块后,我可以使用import:

import myModule from "./myModule.js";

但我不想将模块移到各处。相反,我想使用qjsc首先将代码转换为myModule.cmyModule.o,然后编译qjs并将其用作内置模块。

我的期望是使用qjsc将js代码转换为c,然后使用make qjs将其包含在qjs中,就像QuickJS中的stdos模块一样。

英文:

I read this article: Writing native modules in C for QuickJS engine
.

But I can write the module faster and easier with JS. After creating the module, I can use import:

import myModule from "./myModule.js";

But I don't want to move the module everywhere. Instead I want to use qjsc to convert the code to myModule.c or myModule.o first and then compile qjs and use it as a builtin module.

My expectation is to convert the js code to c with qjsc and then make qjs to include it in qjs, just like the std and os modules in QuickJS.

答案1

得分: 0

我们在这里讨论了这个问题:saghul/txiki.js#386

英文:

We discussed the issue here: saghul/txiki.js#386

huangapple
  • 本文由 发表于 2023年6月12日 17:23:25
  • 转载请务必保留本文链接:https://go.coder-hub.com/76455228.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定