egoist / egoist/tsup

Preserve lib structure when importing it

Open
#704 1 comment 1 reaction 0 assignees View on GitHub
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.