deno.com
在当前页面

Bundler (已弃用)

命令行用法

o bundle [选项]

deno bundle 已在 Deno 2 中移除。

请参阅 Deno 1.x 到 2.x 迁移指南以获取迁移说明:https://docs.deno.com/runtime/manual/advanced/migrate_deprecations


不稳定选项 Jump to heading

--unstable Jump to heading

--unstable 标志已被弃用。请改用细粒度的 --unstable-* 标志.

--unstable-bare-node-builtins Jump to heading

启用不稳定的裸节点内置功能.

--unstable-detect-cjs Jump to heading

在更多情况下将模棱两可的 .js、.jsx、.ts、.tsx 文件视为 CommonJS 模块.

--unstable-sloppy-imports Jump to heading

启用不稳定的通过扩展探测、.js 到 .ts 以及目录探测来解析模块的功能.

Caution

deno bundle 已被弃用,并将在未来的某个版本中移除。请使用 deno_emitesbuildrollup 替代。

deno bundle [URL] 将输出一个供 Deno 使用的单一 JavaScript 文件,其中包含指定输入的所有依赖项。例如:

$ deno bundle https://deno.land/std@0.190.0/examples/colors.tsts colors.bundle.js
Bundle https://deno.land/std@0.190.0/examples/colors.ts
Download https://deno.land/std@0.190.0/examples/colors.ts
Download https://deno.land/std@0.190.0/fmt/colors.ts
Emit "colors.bundle.js" (9.83KB)

如果省略输出文件,打包结果将发送到 stdout

打包后的文件可以像 Deno 中的其他模块一样运行:

deno run colors.bundle.js

输出是一个自包含的 ES 模块,命令行中提供的主模块的任何导出都将可用。例如,如果主模块如下所示:

export { foo } from "./foo.js";

export const bar = "bar";

它可以像这样导入:

import { bar, foo } from "./lib.bundle.js";

为 Web 打包 Jump to heading

deno bundle 的输出旨在供 Deno 使用,而不是用于 Web 浏览器或其他运行时。也就是说,根据输入的不同,它可能在其他环境中也能工作。

如果你希望为 Web 打包,我们推荐使用其他解决方案,例如 esbuild

你找到需要的内容了吗?

隐私政策