英文:
Deno bundle replacement
问题
I can help with the translation:
"你能帮我替换已弃用的 deno bundle
命令吗?
我想将它更改为 esbuild,但运行以下命令:
./node_modules/.bin/esbuild --bundle lib/commands/abc/main.ts --outfile=mod.abc.ts
给我一个错误:
[ERROR] Top-level await is currently not supported with the "iife" output format
我还尝试了 --format=cjs
和 --format=esm
选项,但输出仍然与 deno bundle
输出不同。例如,没有包含导入。
我应该如何使用它?
或者也许你可以帮我找到其他选项?目标是快速删除 deno bundle
而不修改主要代码。"
英文:
Could you please help me with replacing deprecetad deno bundle
command?
I wanted to change it for esbuild, but running a command:
./node_modules/.bin/esbuild --bundle lib/commands/abc/main.ts --outfile=mod.abc.ts
give me an error:
[ERROR] Top-level await is currently not supported with the "iife" output format
I have tried also with --format=cjs
and --format=esm
option, but the output still is different than deno bundle
output. eg. there are not imports included.
How should I use it?
Or maybe can you help me with other option? The goal is to quickly remove deno bundle
without main code modification.
答案1
得分: 2
The esbuild CLI interface does not support bundling of Deno TypeScript module code (at least when using remote imports — e.g. https://deno.land/...
).
The JavaScript API for esbuild can handle those imports by using a plugin that's maintained by one of the Deno core team members: https://github.com/lucacasonato/esbuild_deno_loader
The readme for the plugin explains its usage, and the JavaScript API for esbuild is extensively documented as well: https://esbuild.github.io/
英文:
The esbuild CLI interface does not support bundling of Deno TypeScript module code (at least when using remote imports — e.g. https://deno.land/...
).
The JavaScript API for esbuild can handle those imports by using a plugin that's maintained by one of the Deno core team members: https://github.com/lucacasonato/esbuild_deno_loader
The readme for the plugin explains its usage, and the JavaScript API for esbuild is extensively documented as well: https://esbuild.github.io/
答案2
得分: 1
以下是要翻译的内容:
在当前的 Deno 版本 v1.32.3 中,建议用以下三种方式替代 deno bundle
:
警告 "deno bundle" 已被弃用,将来将被移除。
请改用替代打包工具如 "deno_emit"、"esbuild" 或 "rollup"。
查看:
如果 esbuild 不适用,您可以考虑其他选项。此外,esbuild 还有一个与之相关的项目 deno-esbuild:
Rollup 提供了一些有关 Deno 使用的说明:
deno_emit 是这三者中最适合 Deno 的,它具有类似于已移除的 Deno.emit()
的功能,但作为用户可加载的模块,以避免将其代码包含在主要的 Deno 二进制文件中。原则上,它应该与 deno bundle
最相似,但我不确定它的稳定性如何。
英文:
There are three recommended replacements for deno bundle
in in the current Deno version v1.32.3:
Warning "deno bundle" is deprecated and will be removed in the future.
Use alternative bundlers like "deno_emit", "esbuild" or "rollup" instead.
See:
If esbuild doesn't work then you may check the other ones. Also, esbuild has a project deno-esbuild that might be relevant:
Rollup has some instructions abut Deno usage:
deno_emit is the most Deno-centric from those three - it has similar functionality as the removed Deno.emit()
but as a user loadable module, to avoid including its code in the main Deno binary. In principle it should be the most similar to the deno bundle
but I'm not sure how stable it is already.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论