DEV Community

Kishor Shrestha
Kishor Shrestha

Posted on

2 1

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 (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs