@programmerraj/create-index-js
v5.0.0
Published
Creates an index.js file which exports all the files from a directory.
Downloads
4
Readme
@programmerraj/create-index-js
Creates an index.js file which exports all the files from a directory.
Isn't this so inconvenient:
import a from './dir/a.js'
import b from './dir/b.js'
Instead you can do this:
import { a, b } from './dir/index.js'
./dir/index.js
Will be automatically generated:
export a from './a.js'
export b from './b.js'
Sub directories are also exported:
export { default as goodNumber } from './goodNumber.js'
export { default as isOdd } from './isOdd.js'
export * as fruits from './fruits/index.js'
CLI Usage
create-index-js myDir
Watch Mode
Use -w
or --watch
option to re-create file when files get created or deleted. This mode is efficient because it only re-creates the file when it needs to, and doesn't do any extra file system operations.
Other Options
Do -h
or --help
to see all options
Programmatic Usage
All helper files are exported, but the files that are probably useful are run/run.js
and runWithWatch/runWithWatch.js
.
Run
import { run } from '@programmerraj/create-index-js'
run.run(options)
Run in Watch Mode
import { runWithWatch } from '@programmerraj/create-index-js'
runWithWatch.runWithWatch(options)
Docs
TypeScript types are published. You can see the online TypeDocs at https://chocolateloverraj.github.io/create-index-js.