feat(minfier): support . separated values for compress.treeshake.manualPureFunctions#16529
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. This stack of pull requests is managed by Graphite. Learn more about stacking. |
CodSpeed Performance ReportMerging #16529 will not alter performanceComparing Summary
Footnotes
|
04b0f6a to
fa3aadc
Compare
There was a problem hiding this comment.
Pull request overview
This PR adds support for dot-separated values (e.g., "console.log") in the compress.treeshake.manualPureFunctions configuration option for the minifier. Previously, only simple identifier names were supported (e.g., "foo"). The implementation now handles member expression paths, allowing users to mark specific methods as pure functions for tree-shaking purposes.
Key changes:
- New
is_pure_functionutility inoxc_ecmascript/src/side_effects/pure_function.rsthat matches callees against dotted pure function names - Updated
Ctx::manual_pure_functionsto use the new utility - Comprehensive test coverage including edge cases and examples from Terser and Rollup
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| crates/oxc_ecmascript/src/side_effects/pure_function.rs | New module implementing dotted name matching for pure functions with support for member expressions, chained calls, and optional chaining |
| crates/oxc_ecmascript/src/side_effects/mod.rs | Exports the new is_pure_function utility |
| crates/oxc_minifier/src/ctx.rs | Refactored to use the new is_pure_function utility with redundant empty check |
| crates/oxc_minifier/tests/ecmascript/is_pure_function.rs | Comprehensive unit tests for the new pure function matching logic |
| crates/oxc_minifier/tests/ecmascript/may_have_side_effects.rs | Integration tests for dotted name support and updated to use new utility |
| crates/oxc_minifier/tests/ecmascript/mod.rs | Adds new test module |
| crates/oxc_minifier/tests/peephole/manual_pure_functions.rs | End-to-end tests from Terser demonstrating the feature |
| crates/oxc_minifier/tests/peephole/mod.rs | Adds new test module |
Note: There is a typo in the PR title: "minfier" should be "minifier".
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Merge activity
|
fa3aadc to
c90f053
Compare
### 💥 BREAKING CHANGES - 083fea9 napi/parser: [**BREAKING**] Represent empty optional fields on JS side as `null` (#16411) (overlookmotel) ### 🚀 Features - 7a2afee parser: Add TS1174 error for classes extending multiple base classes (#15993) (sapphi-red) - da87812 semantic: Add TS2309 error for export assignment with other exports (#15992) (sapphi-red) - d6d2bcd minifier: Remove unused function calls that are marked by `manual_pure_functions` (#16534) (sapphi-red) - c90f053 minifier: Support `.` separated values for `compress.treeshake.manualPureFunctions` (#16529) (sapphi-red) - a607cc4 codegen: Preserve comments between CatchClause's param and body (#16167) (copilot-swe-agent) - 8c10694 semantic: Expose get_comment_at method (#16439) (camc314) - 3981e7a ast: Add get_comment_at to lookup a comment by span (#16438) (camc314) ### 🐛 Bug Fixes - 699406a napi/parser: Move `ExportEntry::module_request` field to first (#16412) (overlookmotel) - 12bd794 napi/parser: Move `ExportEntry::module_request` field to last (#16403) (overlookmotel) ### ⚡ Performance - 790beeb napi/parser: Do not remove extraneous options on JS side (#16447) (overlookmotel) Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
### 💥 BREAKING CHANGES - 083fea9 napi/parser: [**BREAKING**] Represent empty optional fields on JS side as `null` (#16411) (overlookmotel) ### 🚀 Features - 7a2afee parser: Add TS1174 error for classes extending multiple base classes (#15993) (sapphi-red) - da87812 semantic: Add TS2309 error for export assignment with other exports (#15992) (sapphi-red) - d6d2bcd minifier: Remove unused function calls that are marked by `manual_pure_functions` (#16534) (sapphi-red) - c90f053 minifier: Support `.` separated values for `compress.treeshake.manualPureFunctions` (#16529) (sapphi-red) - a607cc4 codegen: Preserve comments between CatchClause's param and body (#16167) (copilot-swe-agent) - 8c10694 semantic: Expose get_comment_at method (#16439) (camc314) - 3981e7a ast: Add get_comment_at to lookup a comment by span (#16438) (camc314) ### 🐛 Bug Fixes - 699406a napi/parser: Move `ExportEntry::module_request` field to first (#16412) (overlookmotel) - 12bd794 napi/parser: Move `ExportEntry::module_request` field to last (#16403) (overlookmotel) ### ⚡ Performance - 790beeb napi/parser: Do not remove extraneous options on JS side (#16447) (overlookmotel) Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
…anualPureFunctions` (oxc-project#16529) close oxc-project#16100
### 💥 BREAKING CHANGES - 083fea9 napi/parser: [**BREAKING**] Represent empty optional fields on JS side as `null` (oxc-project#16411) (overlookmotel) ### 🚀 Features - 7a2afee parser: Add TS1174 error for classes extending multiple base classes (oxc-project#15993) (sapphi-red) - da87812 semantic: Add TS2309 error for export assignment with other exports (oxc-project#15992) (sapphi-red) - d6d2bcd minifier: Remove unused function calls that are marked by `manual_pure_functions` (oxc-project#16534) (sapphi-red) - c90f053 minifier: Support `.` separated values for `compress.treeshake.manualPureFunctions` (oxc-project#16529) (sapphi-red) - a607cc4 codegen: Preserve comments between CatchClause's param and body (oxc-project#16167) (copilot-swe-agent) - 8c10694 semantic: Expose get_comment_at method (oxc-project#16439) (camc314) - 3981e7a ast: Add get_comment_at to lookup a comment by span (oxc-project#16438) (camc314) ### 🐛 Bug Fixes - 699406a napi/parser: Move `ExportEntry::module_request` field to first (oxc-project#16412) (overlookmotel) - 12bd794 napi/parser: Move `ExportEntry::module_request` field to last (oxc-project#16403) (overlookmotel) ### ⚡ Performance - 790beeb napi/parser: Do not remove extraneous options on JS side (oxc-project#16447) (overlookmotel) Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>

close #16100