---
title: "Comment by Steve Barakat on \"Publishing TypeScript React components to NPM\" | Hashnode"
description: "Yes. How do you deal with this type of folder structure?"
url: "https://hashnode.com/posts/publishing-typescript-react-components-to-npm/60f30734bb67011cb8369b7f/comment/6147dd45699fe76cd34836bd"
---

[Discussion](https://hashnode.com/posts/publishing-typescript-react-components-to-npm/60f30734bb67011cb8369b7f)

Comment [Publishing TypeScript React components to NPM](https://hashnode.com/posts/publishing-typescript-react-components-to-npm/60f30734bb67011cb8369b7f)

[Steve Barakat](https://hashnode.com/@stevebarakat)

[Sep 20, 2021](https://hashnode.com/posts/publishing-typescript-react-components-to-npm/60f30734bb67011cb8369b7f/comment/6147dd45699fe76cd34836bd)

![Screen Shot 2021-09-19 at 8.57.25 PM.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1632099566224/uR9gfTI81.png) Yes. How do you deal with this type of folder structure?

[Rupert McKay](https://hashnode.com/@fildon)

[Sep 22, 2021](https://hashnode.com/posts/publishing-typescript-react-components-to-npm/60f30734bb67011cb8369b7f/comment/6147dd45699fe76cd34836bd#reply-614b9c8d544e242e0c93db77)

Hey good question!

I recommend having a single higher level index.ts that gathers together everything you want to export from your library. Guessing from the folder structure you have pictured, you could have an index.ts at: `src/index.ts`

Which contains:

```
export { DualRangeSlider } from './components/DualRangeSlider'
export { DualVerticalRangeSlider } from './components/DualVerticalRangeSlider'
// etc
```

Then your build process just needs to point at that single index file to bundle up everything you want your library to expose.

I'm doing this in the example provided in the article, but it's probably not obvious because I only have a single example component to re-export. But that same pattern works for any number of components, as long as they each have an entry in the top-level index file.

I'll make an edit to the article to make this clearer when I have some time on the weekend 🙂

[Steve Barakat](https://hashnode.com/@stevebarakat)

[Sep 24, 2021](https://hashnode.com/posts/publishing-typescript-react-components-to-npm/60f30734bb67011cb8369b7f/comment/6147dd45699fe76cd34836bd#reply-614de96c05ebd95c9caed13e)

[Rupert McKay](https://hashnode.com/@fildon) What's the point in making an `index.ts` file that exports the component from the file it's already being exported from?

`export { Button } from "./Button"`

Is it just for having: `import Button from 'Button'`

instead of: `import Button from 'Button/Button'`

[Rupert McKay](https://hashnode.com/@fildon)

[Oct 18, 2021](https://hashnode.com/posts/publishing-typescript-react-components-to-npm/60f30734bb67011cb8369b7f/comment/6147dd45699fe76cd34836bd#reply-616d2c7c441bd36daa957e07)

[Steve Barakat](https://hashnode.com/@stevebarakat)

Yup, that's exactly it!

I want the code I write to be as easy to use as possible for people that depend on it. Maybe the difference between

`from 'Button/Button'`

and

`from 'Button'`

isn't much, but it is something I can do to help even if only a little. The tradeoff is it means I need to have a top-level index file that re-exports everything from a single entry point.
