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 以取得完整的說明文件。