TypeScript Barrel Generator
Working with TypeScript? Want to make your TypeScript imports cleaner? Use this extension to easily export all modules to a barrel
Info: A "barrel" is a way to rollup exports from several modules into a single convenient module. The barrel itself is a module file that re-exports selected exports of other modules.
export * from './foo';
export * from './bar';
The extension allows you to manually or automatically export the modules to a barrel file. For the automatic way, you first have to create a listener for the folder for which you want to create the automated export.
In both the manual and automatic way, an
index.ts file will be created with a reference to all the folder/files in the current directory.
Info: If there are folders/files you want to get excluded from the export, you can do this by right-clicking on the folder/file and clicking on the
TypeScript: Exclude folder/file from export.
Module creation by listener
Info: When a folder listener is added, it will be visible in the
TypeScript - Export Listeners view. By clicking on the folder names, you will automatically open the
Removing a listener
Folder listeners can be removed by right-clicking on the folder name in the
TypeScript - Export View.
If there are specific folders or files you want to exclude from your module, you can do this by right-clicking on the file, and click on the
TypeScript: Exclude folder/file from export menu action.
Include previously excluded folder(s)/file(s)
When you already excluded a folder or file, and want to include these again into your module export, you can do this from the
TypeScript - Export View. Under the
Excluded folders & files section, right-click on the folder or file to include and click
Include to export.
⚙️ Configuration / Settings
The extension makes use of the following settings:
|Specifies if folder (which contain a
index.ts file) will also be included in the module export.
|Specify which files you want to exclude the
index.ts file. Works on the whole filename or part of the filename.
|Specify the relative paths for the folder listeners. This will make it possible to automatically generate the module export once a file gets added/updated/removed within the specified folder.
To listen to sub-folders, you can include the directory wildcard
** to the path.
|Specify the relative folder/file paths to exclude from the export.
|Specify if you want to enable/disable the usage of semis in the barrel file.
|Specify the character that you want to use as the quoting character; typically
|Specify the message that you want to use in the generated barrel file. The message will be added at the top.
Experiencing any issues, or got feedback to share? Feel free to raise this in the issue list of the repo: issues.