jaredpalmer / tsdx

Zero-config CLI for TypeScript package development
https://tsdx.io
MIT License
11.22k stars 507 forks source link

Export submodules instead of all components in the root #961

Open robertovg opened 3 years ago

robertovg commented 3 years ago

Current Behavior

We are building shared-code projects with tsdx, and we only have one doubt, concern we can't get an answer. How to export subfolders for packages published with TSDX.

Let's use my previous example for the question. In the entry point of our project, we export those two components in the root.

And because of that, when you want to use them we have to import the components from the root of our library (usage example):

import { Thing, SimpleStyledH1Application } from "tsdx-styled-components"

We would like to know how to configure our entry point(s) so we can import our components from subfolders like

import { Thing } from "tsdx-styled-components/things"
import { SimpleStyledH1Application } from "tsdx-styled-components/styled"
import { CoreComponent } from "tsdx-styled-components"

Expected behavior/Suggested solution(s)

To have a guide/notes on how to add subfolders to the libraries we create, so it's easy (not only for me but for anyone using TSDX) how to create libraries with subfolders.

Additional context

Your environment

Example project:

https://github.com/robertovg/tsdx-styled-components/ https://github.com/robertovg/next-ts-styled-components-tsdx-host

robertovg commented 3 years ago

Any updates on thishere?

jblok commented 3 years ago

Would also love to know more about this. Have tried changing the entry and name parameters in the build command, but it's all still exported as index.js

sarmad1995 commented 3 years ago

+1

mixvar commented 3 years ago

I wanted to achieve the same thing ang I think I got it working with tsdx, rollup config override based on the linked stackoverflow threads and some extra bash scripts. The submodule is only in the esm though, so this still is not ideal. In our case moving towards monorepo with multiple separate packages will probably work better.

You can check out the PR here: https://github.com/VirtusLab/formts/pull/83