feat(pack): support emotion react transform#2682
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces comprehensive support for the Emotion React transform, allowing projects to seamlessly integrate Emotion for styling. It provides a new configuration option to activate the transform and ensures its proper application within the compilation pipeline, enhancing styling capabilities for React applications. Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
|
还真有人用这个啊 |
There was a problem hiding this comment.
Code Review
This pull request adds support for Emotion's React transform, which is a great feature. The implementation is mostly correct, with new configuration options, transform logic, and comprehensive tests. I've confirmed the critical issue in the error handling of the new transform rule that could lead to compilation errors, and the minor formatting issue that affects code readability. My review includes suggestions to address these points.
| let module_rule = | ||
| EmotionTransformer::new(&EmotionTransformConfig::default()).map(|transformer| { | ||
| get_ecma_transform_rule(Box::new(transformer), false, EcmascriptTransformStage::Main) | ||
| }); | ||
|
|
||
| Ok(module_rule) |
There was a problem hiding this comment.
The current implementation appears to have a type mismatch that would likely cause a compilation error. Assuming EmotionTransformer::new returns a Result, module_rule would be of type Result<ModuleRule, _>. Wrapping this in Ok() results in a Result<Result<ModuleRule, _>, _>, which does not match the function's required return type of Result<Option<ModuleRule>>.
To fix this and correctly handle potential errors from EmotionTransformer::new, you can chain .map(Some) to the result and return it directly. This will correctly wrap the ModuleRule in an Option while preserving the Result for error propagation.
| let module_rule = | |
| EmotionTransformer::new(&EmotionTransformConfig::default()).map(|transformer| { | |
| get_ecma_transform_rule(Box::new(transformer), false, EcmascriptTransformStage::Main) | |
| }); | |
| Ok(module_rule) | |
| EmotionTransformer::new(&EmotionTransformConfig::default()) | |
| .map(|transformer| { | |
| get_ecma_transform_rule(Box::new(transformer), false, EcmascriptTransformStage::Main) | |
| }) | |
| .map(Some) |
| css_modules::get_auto_css_modules_rule, | ||
| default_export_namer::get_default_export_namer_rule, | ||
| remove_console::get_remove_console_transform_rule, | ||
| emotion::get_emotion_transform_rule, remove_console::get_remove_console_transform_rule, |
There was a problem hiding this comment.
For better readability and to adhere to standard Rust formatting conventions, it's best to have one use path per line within a multi-line use statement.
| emotion::get_emotion_transform_rule, remove_console::get_remove_console_transform_rule, | |
| emotion::get_emotion_transform_rule, | |
| remove_console::get_remove_console_transform_rule, |
|
我记得之前要在 import_map 里配置 emotion 这个包来着,确认下 |
import_source 要处理一下,补了两种测试 case,这个估计后面还要调整一下 |
📊 Performance Benchmark Report (with-antd)Utoopack Performance Report (Intelligent)Report ID: Executive SummaryKey Findings
Workload Distribution by Tier
🤖 AI Intelligent AttributionsNew section mapping granular tasks to bottlenecks. Top 10 Batching CandidatesThese highly-called tasks are dominated by a single parent. If the parent can batch them into one call, it drastically reduces scheduler overhead.
Top 20 Tasks by Total Duration
Duration Distribution
Action Items
Report generated by Intelligent Utoopack Performance Analysis Agent |
Summary
Support
style.emotionto enable emotion react transform to support some internal business project:Compitable with: https://makojs.dev/docs/config#emotion
Test Plan
Added.