Skip to content

A simple utility creating barrel files in TypeScript

Notifications You must be signed in to change notification settings

tgriesser/autobarrel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Jan 30, 2022
01c1b5b · Jan 30, 2022

History

17 Commits
May 17, 2020
Jan 30, 2022
Jan 30, 2022
Jan 30, 2022
May 17, 2020
May 17, 2020
May 17, 2020
May 17, 2020
Jan 30, 2022
Jan 30, 2022
May 17, 2020
May 18, 2020

Repository files navigation

autobarrel

Simple tool for creating "barrel" files in TypeScript

Caveats:

  • Has not been tested on Windows
  • Only meant for TypeScript, as TS will check that there are no conflicting exports
  • Assumes you do not export default or have specific exports in the index. If you need this, exclude and re-export from another module
  • Does not actually check files for the presence of export in ts files
    • Possibly in future scope, PRs welcome. In the meantime use the paths / exclude / ignored options

CLI Usage:

autobarrel [--config path/to/autobarrel.json] [--watch]

autobarrel.json:

{
  /**
   * Relative glob patterns we want to process
   */
  paths: string[]
  /**
   * Relative glob patterns we want to ignore entirely
   */
  ignore?: string[]
  /**
   * Relative glob patterns of files / directories we want to avoid re-exporting
   */
  exclude?: string[]
}

Programmatic Usage:

import { autobarrel, resolveAutobarrelConfig } from "autobarrel"

//
await autobarrel(
  // Converts relative paths to absolute paths for consistency
  await resolveAutobarrelConfig({
    path: path.join(__dirname, "testing", "autobarrel.json"),
  })
)

License

MIT

About

A simple utility creating barrel files in TypeScript

Resources

Stars

Watchers

Forks

Packages

No packages published