Skip to main content
Bun provides a handful of module-specific utilities on the import.meta object. Use import.meta.main to check if the current file is the entrypoint of the current process.
https://mintcdn.com/bun-1dd33a4e-farm-a91c5779-shell-sandbox/CFA6Tagw86uhJFhY/icons/typescript.svg?fit=max&auto=format&n=CFA6Tagw86uhJFhY&q=85&s=b76cf0e4a2c188862bc272cae1c4e52findex.ts
if (import.meta.main) {
  // this file is directly executed with `bun run`
} else {
  // this file is being imported by another file
}

See Docs > API > import.meta for complete documentation.