Bun 在 import.meta
物件上提供了一些模組特定的工具程式。使用 import.meta.main
來檢查目前檔案是否為目前程序的進入點。
if (import.meta.main) {
// this file is directly executed with `bun run`
} else {
// this file is being imported by another file
}
請參閱文件 > API > import.meta 以取得完整文件。