1.0.33 • Published 2 months ago

barrel-tool v1.0.33

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

barrel-tool

image image

Barrel Tool is a utility designed to simplify the generation of "barrels" for your components. Barrels help efficiently organize and export components from multiple files, making their importation more straightforward.

Content

# Installation

Install barrel-tool with npm

npm i -D barrel-tool

or pnpm

pnpm add --save-dev barrel-tool

After that, generate a barrel.config.js

const barrelConfig = {
	dir: [
		// Add your folder names here:  './models', './utils'
	]
};

module.exports = barrelConfig;

# Usage

- Add your directory names

barrel.config.js

const barrelConfig = {
	dir: [
		// For example
		'./models', './libs', './components'
	]
};

module.exports = barrelConfig;

- Generate barrels

npx node node_modules/barrel-tool/src/barrel.generator.js 

- Watch barrels

npx node node_modules/barrel-tool/src/barrel.watch.js

- Add to package.json scripts (optional)

"scripts": {
"barrel-generator": "npx node node_modules/barrel-tool/src/barrel.generator.js",
"barrel-watch": "npx node node_modules/barrel-tool/src/barrel.watch.js"
}

# Settings

- Directory

Specify the directories that will be included in the barrel.

default:

dir: [
	// required
]

Example

dir: [
	'./models', './utils', './components'
]

Example components directory

- Save as

Specify the name of the barrel file. Recommended to use index.ts

default:

saveAs: 'index.ts'

- Use semicolon

Specify if you want to use semicolon at the end of each line.

default:

useSemicolon: false

Example

useSemicolon: true

Example useSemicolon

- Use extension

Specify if you want to use extension at the end of each line.

default:

useExtension: false

Example

useExtension: true

Example useExtension

- Separate by files

Specify if you want to separate the barrel by files.

default:

separateByFiles: false

Example

separateByFiles: true

Example separateByFiles

- Sub-folders

Specify if you want to include sub-folders.

default:

subFolders: true

Example subFolders True

Example

subFolders: false

Example subFolders False

Exclusions

Soon, we will add exclusions.

# Example

barrel.config.js

const barrelConfig = {
	dir: [
		'./components'
	],
	subFolders: false,
	separateByFiles: true,
	useSemicolon: true
}

module.exports = barrelConfig
1.0.33

2 months ago

1.0.2

4 months ago

1.0.29

4 months ago

1.0.1

4 months ago

1.0.28

4 months ago

1.0.211

4 months ago

1.0.27

4 months ago

1.0.210

4 months ago

1.0.3

4 months ago

1.0.22

4 months ago

1.0.32

4 months ago

1.0.21

4 months ago

1.0.31

4 months ago

1.0.26

4 months ago

1.0.25

4 months ago

1.0.24

4 months ago

1.0.23

4 months ago

1.0.0

5 months ago