DEV Community

Kishor Shrestha
Kishor Shrestha

Posted on

 

How to do you preserve directory structure when creating a TS library?

I have created a React UI library to share components between different project in my organization. But, when importing the components I always have to

import {Module} from "my-package"

because when building using Rollup or Webpack, it only output a single bundle. (more if splitting is involved)

This is not optimal. It works but it is not tree-shakeable. How do I preserve the directory structure when build the library or is there any other way to make my imports the following

import Module from "my-package/Module"

Thank you in advance.

Top comments (1)

Need a better mental model for async/await?

Check out this classic DEV post on the subject.

β­οΈπŸŽ€ JavaScript Visualized: Promises & Async/Await

async await