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

🐛[BUG] Attempted import error: 'ColorPicker' is not exported from 'antd' (imported as 'ColorPickerV5').

Open hzwengzhiwei opened this issue 1 year ago • 6 comments
trafficstars

🐛 bug 描述

"@ant-design/pro-components": "2.6.42",
"antd": "4.24.15",

当@ant-design/pro-components版本大于^2.6.42的时候("例如2.6.44、2.6.46"),build会出现如下报错:

[4/4] 🔨  Building fresh packages...
success Saved lockfile.
✨  Done in 44.16s.
yarn run v1.22.19
warning ../../../package.json: No license field
$ craco build
Creating an optimized production build...
Failed to compile.

Attempted import error: 'ColorPicker' is not exported from 'antd' (imported as 'ColorPickerV5').

hzwengzhiwei avatar Jan 15 '24 14:01 hzwengzhiwei

解决了嘛

liqq-cn avatar Jan 18 '24 07:01 liqq-cn

解决了嘛

降低版本即可,2.6.46就会报错

Grey0w0 avatar Jan 18 '24 07:01 Grey0w0

解决了嘛

降低版本即可,2.6.46就会报错

好的,谢谢。其实我想问的是官方有没有解决。现在问题还在,那就是官方也没解决。嗯,所以我在问啥?哈哈

liqq-cn avatar Jan 18 '24 07:01 liqq-cn

  "@ant-design/pro-components": "2.4.4",
    "antd": "4.24.15",

现在使用2.4.4 版本也不行了

feverdestiny avatar Mar 06 '24 01:03 feverdestiny

请问有谁解决了这个问题了吗

jasonChen1234 avatar Mar 17 '24 19:03 jasonChen1234

We ran into this today. After some digging here is what I found:

  1. This PR from December was merged in which updates it to directly use the import: https://github.com/ant-design/pro-components/pull/7952
  2. This code was released in version 2.14.3 of @ant-design/pro-field: https://github.com/ant-design/pro-components/blob/master/packages/field/CHANGELOG.md#2143-2023-12-12
    • @ant-design/pro-field:^2.14.3 then makes it so developers are unable to use @ant-design/pro-components without antd being on a version > 5.5.0 as that is when ColorPicker was introduced
  3. This was released into @ant-design/pro-components in 2.6.44: https://procomponents.ant.design/changelog#ant-designpro-components2644

This could be part of the migration to drop support for Ant v4 as that increases the bundle size. See the discussion here: https://github.com/ant-design/pro-components/issues/8178

A contributor did call out that it would cause ant v4 to not work in the PR but it looks like the error can just be hidden in their webpack config.


A possible(?) solution:

  • Update package.json to use overrides and use the version before this was released:
// package.json
"overrides": {
    "@ant-design/pro-field": "2.14.2"
}

Note however when I tested this locally, this does introduce the new design language from Antv5 and it would probably be best to start the migration from 4 -> 5. I did not test this override locally so cannot confirm it works

kevinguebert avatar Apr 30 '24 20:04 kevinguebert