fix: default theme lost bug if major version mixed in monorepo #1601
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
#1513
💡 需求背景和解决方案 / Background or solution
修复在 monorepo 中同时使用多个不同主版本的 dumi 时,默认主题可能丢失的 bug。
原因:Umi 的路由组件基于文件路径转换成 ChunkName,dumi 2 为了让 ChunkName 保持干净,在 #1513 里用不解析软连接的形式确保绝对路径层级最少(例如
node_modules/dumi/dist/client/pages/404
而不是node_modules/.pnpm/[email protected]_xxxx/node_modules/dumi/dist/client/pages/404
),算是一种绕过的方式;但当 monorepo 下存在多个 dumi 主版本、提取到顶层的版本有可能是 dumi 1 时,就会导致默认主题解析失败(因为 dumi 1 产物里不存在theme-default
文件夹),进而导致产物出问题解法:因为 Umi 不会对
@/
开头的路由组件做转换,所以改用类似@/dumi__pages
的 alias 指向真正的dumi/dist/client/pages
,路由表里直接使用@/dumi__pages/404
以保持路由组件的路径层级足够简洁,进而确保 ChunkName 也是简洁的📝 更新日志 / Changelog