Skip to content

BarrelFile

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

import { BarrelFile } from "@alloy-js/typescript";
<BarrelFile export={boolean | string} path="string" />
exportoptional boolean | stringWhether 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.
pathoptional stringThe name of the source file

This component must be placed directly inside a SourceDirectory component. It will only discover nested barrel files directly within nested source directories.

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

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

The barrel file will contain the following contents:

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