egoist / egoist/tsup

Generated declaration file has incorrect imports

Open
#943 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
11.3k
Forks
275
PR merge metrics
No merged PRs in 30d

Description

Hi there, thanks for creating such an incredible package! I've been trying to setup tsup in the TanStack Query alpha branch, and seem to have an issue generating `.d.ts` files - I've just been falling back to `tsc` (not ideal, especially with the 7.1.0 improvement for ESM/CJS).

In particular, I'm having issues configuring [@tanstack/eslint-plugin-query](https://github.com/TanStack/query/tree/alpha/packages/eslint-plugin-query).

`tsup.config.js`
```
export default defineConfig({
entry: ['src/index.ts'],
format: ['cjs', 'esm'],
target: ['es2020', 'node16'],
outDir: 'build/lib',
external: [/eslint/],
dts: true, // Add this to generate the code below
sourcemap: true,
clean: true,
})
```

After running `pnpm run build:tsup` with `dts` enabled in config:

`build/lib/index.d.ts`
```
export { configs } from './configs/index.ts';
export { rules } from './rules/index.ts';
```

For some reason, it is outputting relative links to `.ts` files which don't exist in the build directory. I wonder if this is something to do with the entry field? Any help would be much appreciated!

Contributor guide

Open the contributing guide

Research direction

Start with the tsup.config.js example and run pnpm run build:tsup with dts enabled. Inspect src/index.ts and the generated build/lib/index.d.ts, comparing its relative imports with the files present in the build directory. Done means the generated declaration file no longer references missing .ts files.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.