feat(napi/playground): call with_private_member_mappings() for private class member mangling#14380
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. |
with_private_member_mappings() in @oxc-project/oxc/files/napi/playground/src/lib.rs like @oxc-project/oxc/pull/14027 didwith_private_member_mappings() support for private class member mangling
CodSpeed Performance ReportMerging #14380 will degrade performances by 3.16%Comparing Summary
Benchmarks breakdown
Footnotes |
|
@copilot fix lint and run |
ccaa262 to
f5efe98
Compare
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
with_private_member_mappings() support for private class member manglingwith_private_member_mappings() support for private class member mangling
There was a problem hiding this comment.
Pull Request Overview
This PR adds support for private member mappings in the NAPI playground, enabling proper mangling of private class members (e.g., #field → #a) similar to the implementation in PR #14027.
Key changes:
- Extended
MinifierReturnstruct to includeclass_private_mappingsfield - Updated
Minifier::build()method to capture and return private member mappings from the Mangler - Refactored method signatures to return
Option<MinifierReturn>instead of tuples for cleaner API
Reviewed Changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| napi/playground/src/lib.rs | Updated minification pipeline to handle MinifierReturn struct and pass private member mappings to codegen |
| crates/oxc_minifier/src/lib.rs | Extended MinifierReturn struct and updated build method to capture class private mappings |
| crates/oxc_minifier/Cargo.toml | Added oxc_index dependency for IndexVec support |
| crates/oxc_mangler/src/lib.rs | Updated build_with_semantic to return private member mappings |
| tasks/track_memory_allocations/allocs_minifier.snap | Updated memory allocation snapshots reflecting code changes |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
with_private_member_mappings() support for private class member manglingwith_private_member_mappings() for private class member mangling
Merge activity
|
…ate class member mangling (#14380) Add `with_private_member_mappings()` support in napi playground like PR #14027 did ## Summary Successfully added support for private member mappings in the napi playground, enabling proper mangling of private class members (e.g., `#field` → `#a`). ## Changes Made: - [x] Update `MinifierReturn` struct to include `class_private_mappings` field - [x] Update `Minifier::build()` method to capture and return `class_private_mappings` from Mangler - [x] Update `apply_minification()` to return `Option<MinifierReturn>` instead of tuple - [x] Update `codegen()` to accept `Option<MinifierReturn>` directly - [x] Refactor `collect_private_members_from_semantic` to be called inside `build_with_semantic` - [x] Fix clippy lint warning - [x] Test the changes to ensure mangling works correctly ## Technical Details: 1. Extended `MinifierReturn` to include `class_private_mappings` field 2. Updated `Minifier::build()` to capture private member mappings 3. **Refactored to return `Option<MinifierReturn>` directly** instead of destructuring into tuple 4. Updated `codegen()` to accept the entire `MinifierReturn` struct 5. **Made `collect_private_members_from_semantic` private and called it inside `build_with_semantic`** 6. Updated `build_with_semantic` to return the collected mappings 7. **Fixed clippy lint** - replaced `.map().unwrap_or()` with `.map_or()` 8. Removed unnecessary imports (`oxc_index`, `oxc_span`, `oxc_syntax`) from playground ## Testing: ✅ All existing tests pass ✅ Mangler tests pass (including `private_member_mangling`) ✅ Minifier tests pass ✅ Manual testing confirms private members are correctly mangled ✅ `just minsize` runs successfully ✅ Clippy warnings fixed The implementation now matches the pattern used in `crates/oxc/src/compiler.rs` from PR #14027. <!-- START COPILOT CODING AGENT SUFFIX --> <details> <summary>Original prompt</summary> > Add `with_private_member_mappings()` in @oxc-project/oxc/files/napi/playground/src/lib.rs like @oxc-project/oxc/pull/14027 did </details> <!-- START COPILOT CODING AGENT TIPS --> --- 💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click [here](https://survey3.medallia.com/?EAHeSx-AP01bZqG0Ld9QLQ) to start the survey.
f5efe98 to
bce31b5
Compare

Add
with_private_member_mappings()support in napi playground like PR #14027 didSummary
Successfully added support for private member mappings in the napi playground, enabling proper mangling of private class members (e.g.,
#field→#a).Changes Made:
MinifierReturnstruct to includeclass_private_mappingsfieldMinifier::build()method to capture and returnclass_private_mappingsfrom Manglerapply_minification()to returnOption<MinifierReturn>instead of tuplecodegen()to acceptOption<MinifierReturn>directlycollect_private_members_from_semanticto be called insidebuild_with_semanticTechnical Details:
MinifierReturnto includeclass_private_mappingsfieldMinifier::build()to capture private member mappingsOption<MinifierReturn>directly instead of destructuring into tuplecodegen()to accept the entireMinifierReturnstructcollect_private_members_from_semanticprivate and called it insidebuild_with_semanticbuild_with_semanticto return the collected mappings.map().unwrap_or()with.map_or()oxc_index,oxc_span,oxc_syntax) from playgroundTesting:
✅ All existing tests pass
✅ Mangler tests pass (including
private_member_mangling)✅ Minifier tests pass
✅ Manual testing confirms private members are correctly mangled
✅
just minsizeruns successfully✅ Clippy warnings fixed
The implementation now matches the pattern used in
crates/oxc/src/compiler.rsfrom PR #14027.Original prompt
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.