Skip to content

fix(eagle): 为 Linaria class 增加版本前缀#1291

Merged
tanbowensg merged 1 commit into
mainfrom
xj/eagle-versioned-linaria-classname
Apr 29, 2026
Merged

fix(eagle): 为 Linaria class 增加版本前缀#1291
tanbowensg merged 1 commit into
mainfrom
xj/eagle-versioned-linaria-classname

Conversation

@netweng
Copy link
Copy Markdown
Member

@netweng netweng commented Apr 29, 2026

变更说明

本次调整 eagle 的 Linaria className 生成规则,在原有 E_${hash} 前缀中加入 @cloudtower/eagle 当前版本号。

变更后 className 格式为:

E_<eagle_version>_<linaria_hash>

例如:

E_4100_0_0_s1n7hav7

这样在不同 eagle 版本共存时,即使 Linaria 原始 hash 相同,也可以通过版本前缀实现样式隔离,降低跨版本样式冲突风险。

实现方式

  • 构建时读取 packages/eagle/package.json 中的 version
  • 将版本号中的非字母数字字符替换为 _
  • rollup.config.js 的 Linaria classNameSlug 中拼接版本前缀

测试建议

  • 已执行:cd packages/eagle && yarn build
  • 建议补充验证:检查 dist/linaria.merged.scssdist/esm/**/*.js 中 className 是否包含当前版本前缀,例如 E_4100_0_0_
image
  • 集成验证:在业务项目中同时加载两个不同版本的 @cloudtower/eagle,确认新版组件样式不会被旧版 style.css 命中或覆盖

cloudtower-sre-island 里调整了 typo.d1_bold_title/d1s_bold_title

image image

tower 中打包的样式已经是不同的 classname 了,无法影响到 font-size 等

image

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 29, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
cloudtower-ui-kit Ready Ready Preview, Comment Apr 29, 2026 3:40am

@chenenpei
Copy link
Copy Markdown
Contributor

LGTM

const projectRootDir = path.resolve(__dirname);
const eagleVersionSlug = JSON.parse(
fs.readFileSync(path.join(__dirname, "package.json"), "utf-8"),
).version.replace(/[^a-zA-Z0-9]+/g, "_");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个 replace 主要是为了兼容性考虑?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

是的

@tanbowensg tanbowensg merged commit 473d29c into main Apr 29, 2026
4 checks passed
@tanbowensg tanbowensg deleted the xj/eagle-versioned-linaria-classname branch April 29, 2026 06:15
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

Successfully merging this pull request may close these issues.

3 participants