create-barrel-file
v1.0.2
Published
## What's a barrel file?
Downloads
3
Readme
Create Barrel File
What's a barrel file?
A barrel file is an index.js
that exports everything from a directory. This allows us to import named exports directly from that directory instead of referencing the filename.
A simple barrel file located in the src/components
directory.
export * from './Container'
export * from './Counter'
export * from './Home'
Now, instead of importing modules based on their specific filenames, we can instead import everything we need in one statement.
A simple usage file located in the src
directory.
import { Container, Counter, Home } from './components'
Install
npm install -g create-barrel-file
Create a Barrel file
Make sure your terminal/command prompt's current directory is the directory where the barrel file should be created. Then enter the following command.
create-barrel-file