create-index icon indicating copy to clipboard operation
create-index copied to clipboard

Importing created subdirectory index files

Open yoiang opened this issue 7 years ago • 5 comments
trafficstars

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!

yoiang avatar Feb 15 '18 22:02 yoiang

+1

anpleenko avatar Feb 17 '18 13:02 anpleenko

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?

SharpSeeEr avatar Mar 06 '19 19:03 SharpSeeEr

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

yoiang avatar Mar 06 '19 20:03 yoiang

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

wjramos avatar Nov 04 '19 17:11 wjramos

@SharpSeeEr There is an even better way:

export * as dirNamedExports from './dir'

ChocolateLoverRaj avatar Mar 11 '22 18:03 ChocolateLoverRaj