debugging add module support

This commit is contained in:
pengfei.zhou
2021-08-24 11:25:06 +08:00
committed by osborn
parent 0ffb14ec72
commit 20e6f5c96d
7 changed files with 65 additions and 4 deletions

View File

@@ -4644,6 +4644,18 @@ function initNativeEnvironment(source) {
const msg = JSON.parse(data);
const payload = msg.payload;
switch (msg.cmd) {
case "":
const { name, content } = payload;
Reflect.apply(jsRegisterModule, undefined, [
name,
Reflect.apply((function (__module) {
eval(`(function (module, exports, require) {
${content}
})(__module, __module.exports, doric.__require__)`);
return __module.exports;
}), undefined, [{ exports: {} }])
]);
break;
case "DEBUG_RES":
const contextId = msg.payload.contextId;
resolve(contextId);