ZenLiuCN / engine

golang js engine base on goja
Apache License 2.0
3 stars 1 forks source link

你好,engine不支持Windows吗? #1

Open wenj91 opened 6 days ago

wenj91 commented 6 days ago

在Windows调试中

import {Second, sleep} from 'golang/time'

new Promise((r, j) => {
    sleep(Second)
    r(1)
}).then(v => {
    console.log(v)
    return new Promise((r, j) => {
        sleep(Second)
        r(v+1)
    })
}).then(v => {
    console.log(v)
    return new Promise((r, j) => {
        sleep(Second)
        r(v+1)
    })
}).then(v => {
    console.log(v)
    return new Promise((r, j) => {
        sleep(Second*2)
        r(v+1)
    })
}).then(v => {
    console.log(v)
    return new Promise((r, j) => {
        sleep(Second*2)
        r(v+1)
    })
})

c, _ := engine.CompileFileWithMapping("main.ts", true) v, err := vm.RunCodeContext(c, time.Second*10, context.Background()) 会抛出异常:

panic: script error: GoError: loading remote module golang/time from D:/code/engine/cmd/test/golang/time fail: Get "d:/code/engine/cmd/test/golang/time": unsupported protocol scheme "d" at github.com/ZenLiuCN/engine.(*Require).Require-fm (native)
Locate: 
github.com/ZenLiuCN/engine.(*Require).Require-fm (native)
main.ts:1:24(4)
github.com/ZenLiuCN/engine.(*Require).Require-fm (native)
main.ts:1:24(4)
ZenLiuCN commented 4 days ago

这个错误是引用的包没找到.看看是否没有使用对应的tag或手动引入包. 所有包都在modules模块. 按需自行引入.

ZenLiuCN commented 4 days ago

全部都引入会太庞大. 按你脚本需要使用的内容.在编译时用 import _ "xxxx" 进行引用即可

wenj91 commented 2 days ago

好的,我试试