An open API service indexing awesome lists of open source software.

https://github.com/estruyf/vscode-typescript-exportallmodules

VSCode extension which generates an `index.ts`barrel file with all the module exports from the current directory
https://github.com/estruyf/vscode-typescript-exportallmodules

folder-listener typescript

Last synced: over 1 year ago
JSON representation

VSCode extension which generates an `index.ts`barrel file with all the module exports from the current directory

Awesome Lists containing this project

README

          



TypeScript Barrel Generator

TypeScript Barrel Generator



Visual Studio Marketplace

Number of installs

Ratings


Buy me a coffee

## ❓ Why

Working with TypeScript? Want to make your TypeScript imports cleaner? Use this extension to easily export all modules to a barrel `index.ts` file.

> **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.

Example:

```typescript
// folder/index.ts
export * from './foo';
export * from './bar';
```

## ✨ Functionalities

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`.

### Create from the current file directory

By using the `Barrel Generator: Export all modules from the current file directory` command, you can create a barrel file from the current file path its directory.

> **Info**: If you want, you can add your own keybinding to this command to make it easier to trigger.

### Manual creation


Manual module export

### Module creation by listener


Export 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 `index.ts` file.

#### Removing a listener

Folder listeners can be removed by right-clicking on the folder name in the `TypeScript - Export View`.


Remove a folder listener

### Excluding folder(s)/file(s)

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.


Excluding folder


Excluding file

#### 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`.


Include to export

## ⚙️ Configuration / Settings

The extension makes use of the following settings:

| Setting | Description | Type | Default |
| --- | --- | --- | --- |
| `exportall.config.namedExports` | Specifies if you want to use named exports in the barrel file. | boolean | `false` |
| `exportall.config.includeFoldersToExport` | Specifies if folder (which contain a `index.ts` file) will also be included in the module export. | boolean | `true` |
| `exportall.config.exclude` | Specify which files you want to exclude the `index.ts` file. Works on the whole filename or part of the filename. | string[] | `['.test.', '.spec.']` |
| `exportall.config.folderListener` | 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. | string[] | `[]` |
| `exportall.config.relExclusion` | Specify the relative folder/file paths to exclude from the export. | `string[]` | `[]` |
| `exportall.config.semis` | Specify if you want to enable/disable the usage of semis in the barrel file. | `boolean` | `true` |
| `exportall.config.quote` | Specify the character that you want to use as the quoting character; typically `'` or `"`. | `string` | `'` |
| `exportall.config.message` | Specify the message that you want to use in the generated barrel file. The message will be added at the top. | `string` | |
| `exportall.config.exportFileExtension` | Specify the file extension to append to the exported files. Example: `js`, `ts`, `null` (no extension). | `string` \| `null` | `null` |


Config settings example

## 💪 Contribute

Experiencing any issues, or got feedback to share? Feel free to raise this in the issue list of the repo: [issues](https://github.com/estruyf/vscode-typescript-exportallmodules/issues).



TypeScript Barrel Generator

## 🔑 License

[MIT](./LICENSE)