pro-components icon indicating copy to clipboard operation
pro-components copied to clipboard

🧐[问题] 旧项目如何快速从单独的子包 import 的格式升级到从 @ant-design/pro-components 包 import 的格式

Open asyncguo opened this issue 3 years ago • 5 comments
trafficstars

🧐 问题描述

旧项目是使用单独子包的形式进行开发的,那统一使用 @ant-design/pro-components 后,如何将之前子包 import 的格式改为从 @ant-design/pro-components 包中 import 的格式呢?

有没有快速统一升级的 codemod 工具

💻 示例代码

# 单独子包 import 的格式
import type { ActionType, ProColumns } from "@ant-design/pro-table";
import ProTable from "@ant-design/pro-table";

期望的代码 import 的格式

# 从 @ant-design/pro-components 包 import 的格式
import type { ActionType, ProColumns } from "@ant-design/pro-components";
import { ProTable } from "@ant-design/pro-components";

asyncguo avatar Oct 14 '22 06:10 asyncguo

好想法 你愿意来练练手吗

chenshuai2144 avatar Oct 14 '22 10:10 chenshuai2144

好想法 你愿意来练练手吗

可以尝试一下,正好最近在看 codemod

asyncguo avatar Oct 14 '22 11:10 asyncguo

可以写在 pro-cli 里面

https://github.com/ant-design/ant-design-pro-cli

chenshuai2144 avatar Oct 16 '22 11:10 chenshuai2144

可以写在 pro-cli 里面

https://github.com/ant-design/ant-design-pro-cli

嗯,我看下了这个库之前的代码是基于 babel 做的 codemod,感觉这个 case 可以使用 jscodeshift 做 codemod,会更加简单些

asyncguo avatar Oct 17 '22 03:10 asyncguo

可以写在 pro-cli 里面

https://github.com/ant-design/ant-design-pro-cli

已提 PR

asyncguo avatar Oct 24 '22 12:10 asyncguo

TAutomatically replying with ChatGPT can be attempted, but it cannot be guaranteed to be completely accurate and may not fully address all issues. Please feel free to reply if you have any further questions or concerns. 此回复基于 ChatGPT 自动生成,可以尝试下方案,官方人员会在一定时间后继续继续处理。

太棒了,我很期待 PR 的合并。如果需要补充信息或者出现问题也可以在这里讨论哦。

chenshuai2144 avatar Mar 10 '23 10:03 chenshuai2144