Open wenj91 opened 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)
这个错误是引用的包没找到.看看是否没有使用对应的tag或手动引入包. 所有包都在modules模块. 按需自行引入.
全部都引入会太庞大. 按你脚本需要使用的内容.在编译时用 import _ "xxxx" 进行引用即可
好的,我试试
在Windows调试中
c, _ := engine.CompileFileWithMapping("main.ts", true) v, err := vm.RunCodeContext(c, time.Second*10, context.Background()) 会抛出异常: