Include/Generate declaration files for bundled external libraries
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 11.3k
- Forks
- 274
- PR merge metrics
- No merged PRs in 30d
Description
We're trying to use tsup to bundle typebox (which is an ESM only library) into a CommonJS library. This works well for the code itself, however we also need to include or generate the type declaration files of typebox to allow its types propagate to consumers.
Is there a way of doing that? It seems that just enabled dts doesn't do the trick.
This is the configuration file I'm using:
import { defineConfig } from 'tsup'
export default defineConfig({
entry: ['src/index.ts'],
format: ['cjs', 'esm'],
dts: {
tsconfig: './tsconfig.lib.json',
},
sourcemap: true,
clean: true,
splitting: false,
treeshake: true,
minify: false,
target: 'es2022',
noExternal: ['typebox'],
esbuildOptions(options) {
options.conditions = ['module']
},
})
Using tsup version 8.5.0.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the declaration build with src/index.ts, tsup 8.5.0, and tsconfig.lib.json using the configuration shown. Inspect how the dts option handles the bundled typebox dependency for both CommonJS and ESM outputs. Done means consumers receive usable declaration files whose typebox types propagate correctly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- build-system, tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100