-
Notifications
You must be signed in to change notification settings - Fork 4.9k
fix: 使用css模块时去掉是否使用过的标识规避多次添加导致hash错乱 #17894
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Walkthrough本次变更在 Changes
Suggested reviewers
Poem
✨ Finishing Touches
🧪 Generate Unit Tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/taro-vite-runner/src/harmony/style.ts(1 hunks)
🧰 Additional context used
🧠 Learnings (1)
packages/taro-vite-runner/src/harmony/style.ts (1)
Learnt from: ianzone
PR: NervJS/taro#17746
File: packages/taro-runtime/tsdown.config.ts:10-16
Timestamp: 2025-05-25T18:02:31.387Z
Learning: 在 taro-runtime 包的 tsdown 配置中,必须禁用 treeshake 来保留 dom-external/index.js 文件。
⏰ Context from checks skipped due to timeout of 90000ms (6)
- GitHub Check: Build Rust Binding / stable - aarch64-apple-darwin
- GitHub Check: Build Rust Binding / stable - x86_64-pc-windows-msvc
- GitHub Check: Build Rust Binding / stable - x86_64-apple-darwin
- GitHub Check: Build Rust Binding / stable - aarch64-apple-darwin
- GitHub Check: Build Rust Binding / stable - x86_64-pc-windows-msvc
- GitHub Check: Build Rust Binding / stable - x86_64-apple-darwin
🔇 Additional comments (1)
packages/taro-vite-runner/src/harmony/style.ts (1)
252-252: #!/bin/bash
echo "===== 插件定义(enforce:pre/post) ====="
rg -C3 "enforce" packages/taro-vite-runner/src/harmony/style.tsecho "===== 搜索直接使用 '?used' 的地方 ====="
rg -n "\?used" packages/taro-vite-runner/src/harmony/style.tsecho "===== compileCSS 调用位置 ====="
rg -n "compileCSS" packages/taro-vite-runner/src/harmony/style.ts
| const { taroConfig } = viteCompilerContext | ||
| const isGlobalModule = taroConfig?.postcss?.cssModules?.config?.namingPattern === 'global' | ||
|
|
||
| id = id.replace('?used', '') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
建议使用 usedRE 正则表达式保持代码一致性
为了与代码库中其他地方的处理方式保持一致,建议使用已定义的 usedRE 正则表达式替代字符串替换。其他地方(第215、268、347行等)都使用了 usedRE 来处理 ?used 标识。
应用此差异来保持一致性:
-id = id.replace('?used', '')
+id = id.replace(usedRE, '')📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| id = id.replace('?used', '') | |
| id = id.replace(usedRE, '') |
🤖 Prompt for AI Agents
In packages/taro-vite-runner/src/harmony/style.ts at line 252, replace the
direct string replacement of '?used' with the predefined regular expression
usedRE to maintain consistency with other parts of the codebase. Locate the
usedRE regex defined elsewhere in the file and use it to perform the replacement
on the id variable instead of using id.replace('?used', '').
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #17894 +/- ##
=======================================
Coverage 55.90% 55.90%
=======================================
Files 417 417
Lines 21693 21693
Branches 5360 5365 +5
=======================================
Hits 12127 12127
+ Misses 7935 7923 -12
- Partials 1631 1643 +12
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
这个 PR 做了什么? (简要描述所做更改)
这个 PR 是什么类型? (至少选择一个)
这个 PR 涉及以下平台:
Summary by CodeRabbit
?used查询参数导致的异常,提升了样式加载的稳定性。