javascript - 无法在 deno exe 中动态导入 typescript 文件
我正尝试根据一些 用户 输入 使用其公共链接从 aws 在 exe 中导入文件,但无法做到
例如,我使用以下命令创建了我的 exe
deno compile --allow-all main.ts
用户使用类似 ./exe --qId 345 的命令运行这个 exe。我在 exe 中解析这个 qId 并从公共链接加载一些文件,如下所示
let { runTestCases } = await import ("https://test-cases.nyc3.digitaloceanspaces.com/<qId>.ts")
但它给了我以下错误
TypeError: Module not found
at async getQuestionTestCaseFile (file:///F:/CodeQuotient/Deno_exe/deno/Controllers/question_controller.ts:47:37)
at async file:///F:/CodeQuotient/Deno_exe/deno/main.ts:14:1
当我使用以下命令运行它时,它运行良好
deno run --allow-all main.ts
我想知道是否有可能在 exe 中像这样动态导入模块。
有没有其他方法可以实现这个?
答案#1
截至 Deno 版本
1.29.1:
“Dynamic” import() 当前在 deno compile 中不受支持。
这是一个已知问题,正在项目仓库的以下 GitHub 问题中跟踪:
denoland/deno#8655 - deno compile 不支持动态导入