Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

能否将使用了ts-node的地方,都使用importx库重构? #211

Closed
Groupguanfang opened this issue Oct 19, 2024 · 1 comment
Closed
Assignees

Comments

@Groupguanfang
Copy link
Contributor

Groupguanfang commented Oct 19, 2024

importx是由antfu大佬近几个月发的新包,可以查看它的README了解一系列的加载机制:https://github.com/antfu-collective/importx

使用importx重构之后不会再出现以下问题:

  • 项目中的package.json设置为type: module的时候,由于框架不支持ESM,很多地方都用了require函数,会直接报错;
  • 其他的包/库设置了type: module,或者只提供了ESM产物(如chalk@latest等),由于是require进来的,所以也会直接报错(特别是在Webpack Hook中使用unplugin的时候,很多插件都不能用,都是报错的)。

目前我发现两个具体要修改的类有:

@muxiangqiu muxiangqiu self-assigned this Oct 20, 2024
muxiangqiu pushed a commit that referenced this issue Oct 20, 2024
…quire #211 (#212)

feat: 将 @celljs/cli-common 改为使用 importx-tsup 包进行动态 require
---------

Co-authored-by: Naily <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants