Skip to content

Comments

feat(napi/playground): call with_private_member_mappings() for private class member mangling#14380

Merged
graphite-app[bot] merged 1 commit intomainfrom
copilot/fix-d9dce2c6-b15d-4a0f-861c-6e7ac12b07fe
Oct 7, 2025
Merged

feat(napi/playground): call with_private_member_mappings() for private class member mangling#14380
graphite-app[bot] merged 1 commit intomainfrom
copilot/fix-d9dce2c6-b15d-4a0f-861c-6e7ac12b07fe

Conversation

Copy link
Contributor

Copilot AI commented Oct 6, 2025

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:

  • Update MinifierReturn struct to include class_private_mappings field
  • Update Minifier::build() method to capture and return class_private_mappings from Mangler
  • Update apply_minification() to return Option<MinifierReturn> instead of tuple
  • Update codegen() to accept Option<MinifierReturn> directly
  • Refactor collect_private_members_from_semantic to be called inside build_with_semantic
  • Fix clippy lint warning
  • 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.

Original prompt

Add with_private_member_mappings() in @oxc-project/oxc/files/napi/playground/src/lib.rs like @oxc-project/oxc/pull/14027 did


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

@graphite-app
Copy link
Contributor

graphite-app bot commented Oct 6, 2025

How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

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.

Copilot AI changed the title [WIP] Add with_private_member_mappings() in @oxc-project/oxc/files/napi/playground/src/lib.rs like @oxc-project/oxc/pull/14027 did feat(napi/playground): Add with_private_member_mappings() support for private class member mangling Oct 6, 2025
Copilot AI requested a review from sapphi-red October 6, 2025 14:50
Copilot AI requested a review from sapphi-red October 7, 2025 01:24
@github-actions github-actions bot added A-minifier Area - Minifier C-enhancement Category - New feature or request labels Oct 7, 2025
@codspeed-hq
Copy link

codspeed-hq bot commented Oct 7, 2025

CodSpeed Performance Report

Merging #14380 will degrade performances by 3.16%

Comparing copilot/fix-d9dce2c6-b15d-4a0f-861c-6e7ac12b07fe (bce31b5) with main (d1ff718)1

Summary

❌ 1 regression
✅ 36 untouched

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Benchmarks breakdown

Mode Benchmark BASE HEAD Change
Instrumentation mangler[RadixUIAdoptionSection.jsx] 12.6 µs 13 µs -3.16%

Footnotes

  1. No successful run was found on main (bce31b5) during the generation of this report, so d1ff718 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@sapphi-red
Copy link
Member

@copilot fix lint and run just minsize

Copy link
Contributor Author

Copilot AI commented Oct 7, 2025

@copilot fix lint and run just minsize

Done in commit 6b458c7. Fixed clippy lint warning (replaced .map().unwrap_or() with .map_or()), and just minsize runs successfully showing improvements in minified output sizes.

@sapphi-red sapphi-red force-pushed the copilot/fix-d9dce2c6-b15d-4a0f-861c-6e7ac12b07fe branch from ccaa262 to f5efe98 Compare October 7, 2025 04:29
Copy link
Member


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

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.

@sapphi-red sapphi-red changed the title feat(napi/playground): Add with_private_member_mappings() support for private class member mangling feat(napi/playground): add with_private_member_mappings() support for private class member mangling Oct 7, 2025
@sapphi-red sapphi-red marked this pull request as ready for review October 7, 2025 05:09
Copilot AI review requested due to automatic review settings October 7, 2025 05:09
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 MinifierReturn struct to include class_private_mappings field
  • 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.

@sapphi-red sapphi-red assigned Boshen and unassigned sapphi-red Oct 7, 2025
@sapphi-red sapphi-red requested a review from Boshen October 7, 2025 05:10
@sapphi-red sapphi-red changed the title feat(napi/playground): add with_private_member_mappings() support for private class member mangling feat(napi/playground): call with_private_member_mappings() for private class member mangling Oct 7, 2025
@Boshen Boshen added the 0-merge Merge with Graphite Merge Queue label Oct 7, 2025
Copy link
Member

Boshen commented Oct 7, 2025

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.
@graphite-app graphite-app bot force-pushed the copilot/fix-d9dce2c6-b15d-4a0f-861c-6e7ac12b07fe branch from f5efe98 to bce31b5 Compare October 7, 2025 07:52
@graphite-app graphite-app bot merged commit bce31b5 into main Oct 7, 2025
27 checks passed
@graphite-app graphite-app bot deleted the copilot/fix-d9dce2c6-b15d-4a0f-861c-6e7ac12b07fe branch October 7, 2025 07:58
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Oct 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-minifier Area - Minifier C-enhancement Category - New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants