Documentation Index
Fetch the complete documentation index at: https://bun.zhcndoc.com/llms.txt
Use this file to discover all available pages before exploring further.
Bun 原生支持 .json 导入。
{
"name": "bun",
"version": "1.0.0",
"author": {
"name": "John Dough",
"email": "[email protected]"
}
}
像导入其他源文件一样导入该文件。
data.tsimport data from "./package.json";
data.name; // => "bun"
data.version; // => "1.0.0"
data.author.name; // => "John Dough"
Bun 还支持 导入属性 和 JSON 模块 语法。
data.tsimport data from "./package.json" with { type: "json" };
data.name; // => "bun"
data.version; // => "1.0.0"
data.author.name; // => "John Dough"
更多关于在 Bun 中使用 TypeScript 的信息,请参见 文档 > 运行时 > TypeScript。