gajus / create-index

Creates ES6 ./index.js file in target directories that imports and exports all sibling files and directories.
Other
278 stars 87 forks source link

Make it possible to configure origin of `default` export #47

Closed fb55 closed 4 years ago

fb55 commented 6 years ago

Right now, a file called default will be added as the default export. This PR adds a default option that can be used to change this.

By setting it to match, the default export will be set to a file matching the name of the current directory.

fb55 commented 6 years ago

@gajus Would appreciate a review!

gajus commented 6 years ago

What is the use case for this?

fb55 commented 6 years ago

This patch gives you a more straight-forward (and less accidental) naming convention for default exports.

The intended use is for an application where components live in files named ComponentName/ComponentName.js. We create ComponentName/index.js files re-exporting the component so you can just import Component from ComponentName.