feat!: Consolidate Metadata Transformation Options into descriptorFields#208
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #208 +/- ##
==========================================
+ Coverage 93.01% 93.23% +0.22%
==========================================
Files 8 8
Lines 1531 1581 +50
==========================================
+ Hits 1424 1474 +50
Misses 107 107
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
03ca76e to
0fdcc91
Compare
There was a problem hiding this comment.
Pull request overview
This PR introduces a new descriptorFields option to control which message-descriptor properties (e.g., message, context, comment) are preserved during SWC macro transformation, replacing the previous boolean stripNonEssentialFields behavior and aligning with the related Babel change.
Changes:
- Add
DescriptorFieldsenum and replacestrip_non_essential_fieldswithdescriptor_fieldsacross config parsing and runtime options (withautoenv-based defaults). - Update macro transforms to conditionally emit
message,context, andcommentbased ondescriptor_fields. - Update docs, tests, and SWC snapshot fixtures to cover the new configuration modes (
id-only,message, etc.).
Reviewed changes
Copilot reviewed 12 out of 16 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
src/options.rs |
Introduces DescriptorFields, updates config parsing/defaulting, and replaces the old boolean option. |
src/lib.rs |
Updates JSX macro transform to conditionally include descriptor fields and exports DescriptorFields. |
src/js_macro_folder.rs |
Updates JS macro transforms (t, defineMessage, etc.) to respect descriptor_fields for message/context/comment. |
README.md |
Documents descriptorFields behavior and supported values. |
tests/jsx.rs |
Adjusts tests to use descriptor_fields and adds coverage for "message" mode. |
tests/jsx_icu.rs |
Adjusts tests to use descriptor_fields and adds coverage for "message" mode with ICU JSX. |
tests/js_t.rs |
Adjusts tests to use descriptor_fields and adds coverage for "message" mode. |
tests/js_define_message.rs |
Adjusts tests to use descriptor_fields and adds coverage for "message" mode. |
tests/__swc_snapshots__/... |
Updates/adds snapshots reflecting new field-preservation behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@timofei-iatsenko please take a look at the failing formatting check |
Related PR in Babel version: lingui/js-lingui#2513
Related issue: lingui/js-lingui#2511