Preserve lib structure when importing it
- Dominant language
- TypeScript
- Stars
- 11.3k
- Forks
- 275
- PR merge metrics
- No merged PRs in 30d
Description
Is it possible to preserve the import structure of the library when it is being imported elsewhere?
For example,
I have `src/index.tsx` and `src/components/index.tsx`. I create a few entry points in `package.json`:
```json
{
"name": "ui",
"version": "0.0.0",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"sideEffects": false,
"private": true,
"scripts": {
"build": "tsup",
"clean": "rm -rf dist",
"dev": "tsup --watch",
"lint": "eslint src/*.ts*"
},
"files": [
"dist",
"src"
],
"devDependencies": {
},
"tsup": {
"splitting": false,
"sourcemap": true,
"clean": true,
"dts": true,
"external": [
"react"
],
"format": [
"esm",
"cjs"
],
"entryPoints": [
"src/index.tsx",
"src/components/index.tsx"
]
}
}
```
From the app, I want to use import the lib in this way:
`import { Button } from "ui/components"` but I am only allowed to import either in this way: `import { Button } from "ui"` or `import { Button } from "ui/dist/components"`
Contributor guide
Assessment
This issue has not been assessed yet.