fix: ignore browserslist config when compiling demo in v1 #1825
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🤔 这个变动的性质是?/ What is the nature of this change?
🔗 相关 Issue / Related Issue
#1817
ant-design/ant-design-pro#10829
💡 需求背景和解决方案 / Background or solution
修复 dumi v1 在 package.json 包含
browserslist
配置时,demo 编译可能报错的问题。该 PR 是 #1817 的补充,锁定 babel 版本只能解一小部分问题,在 ant-design-pro 项目中报错的真正原因是 package.json 配置中的
browserslist
配置值为百分比,但 browserslist 版本和 babel 版本对不上导致 targets 校验报错,解法是为 demo 编译的 babel 配置启用ignoreBrowserslistConfig
配置项。补充:
dumi demo 编译也是使用的 Umi 的 babel 配置,为什么 Umi 的 babel 编译不会报错而 dumi 的 demo 编译会报错?因为 babel 仅在未配置
targets
时才会尝试读取browserslist
配置,Umi 层默认有targets
所以不受影响,而 dumi demo 编译为了提升编译效率,没有配置targets
所以走了自动读取browserslist
的逻辑。📝 更新日志 / Changelog