Files
bun.sh/docs/guides/util/entrypoint.mdx
2025-11-21 14:06:19 -08:00

20 lines
610 B
Plaintext

---
title: Check if the current file is the entrypoint
sidebarTitle: Check entrypoint
mode: center
---
Bun provides a handful of module-specific utilities on the [`import.meta`](/runtime/module-resolution#import-meta) object. Use `import.meta.main` to check if the current file is the entrypoint of the current process.
```ts index.ts icon="/icons/typescript.svg"
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](/runtime/module-resolution#import-meta) for complete documentation.