# BarrelFile

Creates a source file which re-exports the exports in other files and nested barrel files in the source directory its placed in.

* jsx

  ```tsx
  import { BarrelFile } from "@alloy-js/typescript";


  <BarrelFile export={boolean | string} path="string" />
  ```

* stc

  ```ts
  import { BarrelFile } from "@alloy-js/typescript/stc";


  BarrelFile({ export: boolean | string, path: string }).children(children)
  ```

## Props

|        |                            |                                                                                                                                                                                                |
| ------ | -------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| export | optional boolean \| string | Whether the source file is exported out of the package. When true, this source file with its source file relative to the project root. Otherwise, it will be exported with the specified path. |
| path   | optional string            | The name of the source file                                                                                                                                                                    |

## Remarks

This component must be placed directly inside a [SourceDirectory](../../../core/components/sourcedirectory/) component. It will only discover nested barrel files directly within nested source directories.

## Example

Creating a barrel file which exports the two other source files in the same directory

```tsx
<Output>
  <SourceDirectory path="src">
    <SourceFile path="one.ts" />
    <SourceFile path="two.ts" />
    <BarrelFile />
  </SourceDirectory>
</Output>
```

The barrel file will contain the following contents:

```ts
export * from "./one.js";
export * from "./two.js";
```

## See also

* [SourceDirectory](../../../core/components/sourcedirectory/)
* [SourceFile](../sourcefile/)
