My FeedDiscussionsHeadless CMS
New
Sign in
Log inSign up
Learn more about Hashnode Headless CMSHashnode Headless CMS
Collaborate seamlessly with Hashnode Headless CMS for Enterprise.
Upgrade ✨Learn more

index.ts vs subComponent1.ts

J Kristoffer M Sanio's photo
J Kristoffer M Sanio
·Mar 24, 2017

./subComponent1/subComponent1.ts

25%

./subComponent1/index.ts

75%

4 votes · Closed

When building large scale applications, I divide my components into folders. However I the dilemma of naming the main file inside them.

Naming them index.ts allows me to require them like this

let { subModule1 } = require('./subModule/');

Which is really aesthetically pleasing and half the length, especially when you're requiring a lot of stuff.

The downside is, you end up with having multiple index.ts files to wrangle around with. At least that's that issue I'm facing.

I was wondering how to others go about this and what's their rational for their decisions.