要在 Bun 中将 .html 文件作为文本文件导入,请在导入语句中使用 type: "text" 属性。
import html from "./file.html" with { type: "text" };
console.log(html); // <!DOCTYPE html><html><head>...
这也可以与热模块重新加载和/或监视模式一起使用,以便在 ./file.html 文件更改时强制 Bun 重新加载。
此功能已在 Bun v1.1.5 中添加。
要在 Bun 中将 .html 文件作为文本文件导入,请在导入语句中使用 type: "text" 属性。
import html from "./file.html" with { type: "text" };
console.log(html); // <!DOCTYPE html><html><head>...
这也可以与热模块重新加载和/或监视模式一起使用,以便在 ./file.html 文件更改时强制 Bun 重新加载。
此功能已在 Bun v1.1.5 中添加。
HTTP
包管理器
将 bun install 与 Artifactory 一起使用
配置 Git 以 diff Bun 的 lockb lockfile
读取文件
运行时
流
将 ReadableStream 转换为 Uint8Array
将 ReadableStream 转换为 ArrayBuffer
将 Node.js Readable 转换为 Uint8Array
实用程序