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

👑 [需求] 能排除掉 reactflow 的依赖吗? #312

Closed
yangfuhai opened this issue Sep 1, 2024 · 3 comments
Closed

👑 [需求] 能排除掉 reactflow 的依赖吗? #312

yangfuhai opened this issue Sep 1, 2024 · 3 comments

Comments

@yangfuhai
Copy link

🥰 需求描述

项目中有用到最新版本的 reactflow,而 pro-chat 中也通过 pro-editor 依赖了这个,但是在实际应用中, pro-chat 没有场景使用到 reactflow。 能否排除掉这个依赖?

@AmAzing129
Copy link
Collaborator

排除依赖指的是希望 node_modules 下不存在这个包吗?具体问题场景是什么,与项目中显式安装的 reactflow 版本冲突么?似乎是包管理的问题,而不是 prochat 的问题,需要提供更多细节

@AmAzing129 AmAzing129 added the question Further information is requested label Sep 1, 2024
@yangfuhai
Copy link
Author

排除依赖指的是希望 node_modules 下不存在这个包吗?具体问题场景是什么,与项目中显式安装的 reactflow 版本冲突么?似乎是包管理的问题,而不是 prochat 的问题,需要提供更多细节

@AmAzing129 是的,当项目安装 pro-chat 时,会在 node_modules 下安装有低版本的 reactflow,而目前最新的 reactflow 已经换成了 “@xyflow/react”, 这两个库的 api,类名是完全一样的。

所以希望 pro-chat 能以移除掉旧的 reactflow(所谓的移除是希望安装 pro-chat 的时候, node-modules 下不要带有 reactflow 了),或者也可以 reactflow 升级到最新版本的 “@xyflow/react”

@AmAzing129
Copy link
Collaborator

  • 首先不确定这个诉求是否合理,毕竟,同一项目下存在不同版本的依赖很正常。假定就是要实现:

  • 移除暂时做不了,因为这是 pro-editor 的依赖;未来会考虑脱离 pro-editor

  • 可以在 package.json 中增加,以使用新版本覆盖旧版本

"overrides": {
  "reactflow": "npm:@xyflow/[email protected]"
}

这两个库的 api,类名是完全一样的

但实际上,The package reactflow has been renamed to @xyflow/react and it's not a default import anymore. 导入方式产生了变化。

所以开发态取决于你的构建工具,比如 vite 直接跑会报错,next.js 试了一下正常运行。需要自行处理了。

部署时有 treeshaking 不影响。

@AmAzing129 AmAzing129 removed the question Further information is requested label Sep 4, 2024
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