egoist / egoist/tsup

Problem:tsup 构建出现别名引用错误,造成循环引用声明

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

Description

我最近在做将 某个主项目 的类型进行打包输出为到指定文件夹,我的主项目中含有(declare.ts)

![Image](https://github.com/user-attachments/assets/e1ce5b4a-f556-4523-923e-c327694eae69)
然后在 tsconfig.json 的 types 中指定了一个文件夹,文件夹中含有类型 index.d.ts,内容为:

![Image](https://github.com/user-attachments/assets/7b77fa5b-6cd7-478a-b41c-44cb062a5972)

其中将主项目中的类型通过一系列组合成一个比较大的命名空间:Rapid。然后可以在项目的任何地方使用这个较大的命名空间。在我的主项目中,使用正常。

然后我配置了 tsup,以 tsconfig.json 的 types 为入口进行打包(包含上述的 index.d.ts),以及我的主项目中所对于的 ts 文件作为入口(包含上述 declare.ts ),同时进行打包。
但是打包输出的最终文件中,出现了引用混乱

![Image](https://github.com/user-attachments/assets/094d9127-ff5d-4abb-b9d0-d2874a7df221)

最终生成的声明文件中,tsup错误的修改了我的文件的导入别名,并且在我声明全局的命名空间时,给我造成了循环引用。

Contributor guide

Open the contributing guide

Research direction

Start with the tsconfig.json types setting, declare.ts, and the referenced index.d.ts, then inspect the tsup configuration that bundles them with the project entry TypeScript files. Reproduce the declaration build and compare the input aliases with the generated declarations. Done means the output preserves the intended aliases and does not create a circular reference around the global Rapid namespace.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.