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

Importing created subdirectory index files #44

Open yoiang opened 6 years ago

yoiang commented 6 years ago

Hello! Thanks so much for the great work on create-index! I apologize if this has been brought up before, after some time of searching the issues and pull requests I could not find mention of it.

I have a library project with some deeper source folders and much to my delight create-index does indeed create index.js files exactly how I was looking for, short of one thing. When creating a parent folder's index.js and using the recurse into subfolders option the parent folder's index.js will not import the child folder's. To further call the inconsistency out, subsequent runs of create-index will properly import the child folder's now created index.js.

I'd be happy to submit a PR if this seems like a feature that should be included, especially if it's something someone unfamiliar with the source can easily jump in and do, say if it's a matter of swapping the order of generation.

Thank you for your time!

anpleenko commented 6 years ago

+1

SharpSeeEr commented 5 years ago

I have this issue as well, but I find the parent folder index.js imports the child folder the same as if it were a file, which is giving me errors:

export { default as dirname } from './dirname';

I believe (and could definitely be wrong) it should import the directory like this (and this works in my projects):

import * as dirname from './dirname';

export { dirname };

@yoiang - Is this similar to your issue/findings?

yoiang commented 5 years ago

@SharpSeeEr I don't recall, it's been a while. Sorry~!

wjramos commented 5 years ago

I am seeing the same issue, create-index does not handle named exports at all

ChocolateLoverRaj commented 2 years ago

@SharpSeeEr There is an even better way:

export * as dirNamedExports from './dir'