要在 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
實用程式