-
-
Notifications
You must be signed in to change notification settings - Fork 788
feat(minifier): disable removal of unnecessary use strict directives for DCE
#15691
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(minifier): disable removal of unnecessary use strict directives for DCE
#15691
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 #15691 will not alter performanceComparing Summary
Footnotes
|
There was a problem hiding this 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 introduces a configuration option to disable the removal of unnecessary use strict directives during Dead Code Elimination (DCE). This is a workaround for rolldown issues #6879 and #6880 until proper ModuleKind handling is implemented.
Key changes:
- Added
remove_unnecessary_use_strictboolean flag toNormalizeOptions - DCE path now preserves
use strictdirectives while the regular compressor still removes them - Added test coverage to ensure
use strictdirectives are preserved during DCE
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
crates/oxc_minifier/src/peephole/normalize.rs |
Added new remove_unnecessary_use_strict option to NormalizeOptions struct and conditionally applied it in exit_program and exit_function_body methods |
crates/oxc_minifier/src/compressor.rs |
Configured the new option: true for regular compression and false for DCE |
crates/oxc_minifier/tests/peephole/dead_code_elimination.rs |
Added test case to verify use strict directives are preserved during DCE |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Merge activity
|
…s for DCE (#15691) This is kind of a workaround. The target of this PR is to solve rolldown/rolldown#6879 and rolldown/rolldown#6880. While the proper way to fix them is to use the proper `ModuleKind` (described in rolldown/rolldown#7009), `ModuleKind::Unambiguous` doesn't work as expected and is blocked by #15541. So for the meanwhile, this PR can solve those issues indirectly. We can revert this PR once the issues above are solved properly, but I guess it's also fine to keep it as I think there's less value to remove `use strict` directives in DCE.
87657e1 to
56e7e44
Compare
### 💥 BREAKING CHANGES - ea51b0b napi: [**BREAKING**] Standardize function naming with sync suffixes (#15661) (Boshen) ### 🚀 Features - 77efb76 parser: Improve error message for invalid switch clauses (#15728) (sapphi-red) - 5691727 parser: Improve `import source` `from` error message (#15727) (sapphi-red) - b7404bc parser: Improve error message for missing function body (#15726) (sapphi-red) - 71c2fb0 parser: Improve error message when JSX is found while not enabled (#15725) (sapphi-red) - 56e7e44 minifier: Disable removal of unnecessary `use strict` directives for DCE (#15691) (sapphi-red) - 8a61cfd allocator, ast: Introduce `UnstableAddress` trait (#15700) (overlookmotel) - f5ce55a napi: Export all options using wildcard exports (Boshen) - 68703b9 minifier: Rotate binary expressions to remove parentheses (#15473) (sapphi-red) ### 🐛 Bug Fixes - c023ba6 semantic: Do not duplicate statements in temp `Vec` when binding `TSModuleDeclaration`s (#15724) (overlookmotel) - d60ca81 parser: Reject `import something 'source'` (#15746) (sapphi-red) - e0728fa ast: Exclude comment end position from `is_inside_comment` check (#15753) (camc314) - 9f54a36 semantic: Error on `\00` in strict mode (#15743) (sapphi-red) - 440a977 ast: Include rest properties when using `get_binding_identifiers` (#15710) (camc314) ### ⚡ Performance - 1f09d3c parser: Faster checking for invalid modifiers (#15717) (overlookmotel) - d8d4e31 ast: Use loop instead of recursion in `TSModuleDeclarationBody::as_module_block_mut` (#15713) (overlookmotel) ### 📚 Documentation - e033d50 ast: Clarify behavior of `TSModuleDeclaration::has_use_strict_directive` (#15730) (overlookmotel) - 9eda70f allocator: Improve docs for `Address` methods (#15697) (overlookmotel)
### 💥 BREAKING CHANGES - ea51b0b napi: [**BREAKING**] Standardize function naming with sync suffixes (#15661) (Boshen) ### 🚀 Features - 77efb76 parser: Improve error message for invalid switch clauses (#15728) (sapphi-red) - 5691727 parser: Improve `import source` `from` error message (#15727) (sapphi-red) - b7404bc parser: Improve error message for missing function body (#15726) (sapphi-red) - 71c2fb0 parser: Improve error message when JSX is found while not enabled (#15725) (sapphi-red) - 56e7e44 minifier: Disable removal of unnecessary `use strict` directives for DCE (#15691) (sapphi-red) - 8a61cfd allocator, ast: Introduce `UnstableAddress` trait (#15700) (overlookmotel) - f5ce55a napi: Export all options using wildcard exports (Boshen) - 68703b9 minifier: Rotate binary expressions to remove parentheses (#15473) (sapphi-red) ### 🐛 Bug Fixes - c023ba6 semantic: Do not duplicate statements in temp `Vec` when binding `TSModuleDeclaration`s (#15724) (overlookmotel) - d60ca81 parser: Reject `import something 'source'` (#15746) (sapphi-red) - e0728fa ast: Exclude comment end position from `is_inside_comment` check (#15753) (camc314) - 9f54a36 semantic: Error on `\00` in strict mode (#15743) (sapphi-red) - 440a977 ast: Include rest properties when using `get_binding_identifiers` (#15710) (camc314) ### ⚡ Performance - 1f09d3c parser: Faster checking for invalid modifiers (#15717) (overlookmotel) - d8d4e31 ast: Use loop instead of recursion in `TSModuleDeclarationBody::as_module_block_mut` (#15713) (overlookmotel) ### 📚 Documentation - e033d50 ast: Clarify behavior of `TSModuleDeclaration::has_use_strict_directive` (#15730) (overlookmotel) - 9eda70f allocator: Improve docs for `Address` methods (#15697) (overlookmotel)
…s for DCE (oxc-project#15691) This is kind of a workaround. The target of this PR is to solve rolldown/rolldown#6879 and rolldown/rolldown#6880. While the proper way to fix them is to use the proper `ModuleKind` (described in rolldown/rolldown#7009), `ModuleKind::Unambiguous` doesn't work as expected and is blocked by oxc-project#15541. So for the meanwhile, this PR can solve those issues indirectly. We can revert this PR once the issues above are solved properly, but I guess it's also fine to keep it as I think there's less value to remove `use strict` directives in DCE.
### 💥 BREAKING CHANGES - ea51b0b napi: [**BREAKING**] Standardize function naming with sync suffixes (oxc-project#15661) (Boshen) ### 🚀 Features - 77efb76 parser: Improve error message for invalid switch clauses (oxc-project#15728) (sapphi-red) - 5691727 parser: Improve `import source` `from` error message (oxc-project#15727) (sapphi-red) - b7404bc parser: Improve error message for missing function body (oxc-project#15726) (sapphi-red) - 71c2fb0 parser: Improve error message when JSX is found while not enabled (oxc-project#15725) (sapphi-red) - 56e7e44 minifier: Disable removal of unnecessary `use strict` directives for DCE (oxc-project#15691) (sapphi-red) - 8a61cfd allocator, ast: Introduce `UnstableAddress` trait (oxc-project#15700) (overlookmotel) - f5ce55a napi: Export all options using wildcard exports (Boshen) - 68703b9 minifier: Rotate binary expressions to remove parentheses (oxc-project#15473) (sapphi-red) ### 🐛 Bug Fixes - c023ba6 semantic: Do not duplicate statements in temp `Vec` when binding `TSModuleDeclaration`s (oxc-project#15724) (overlookmotel) - d60ca81 parser: Reject `import something 'source'` (oxc-project#15746) (sapphi-red) - e0728fa ast: Exclude comment end position from `is_inside_comment` check (oxc-project#15753) (camc314) - 9f54a36 semantic: Error on `\00` in strict mode (oxc-project#15743) (sapphi-red) - 440a977 ast: Include rest properties when using `get_binding_identifiers` (oxc-project#15710) (camc314) ### ⚡ Performance - 1f09d3c parser: Faster checking for invalid modifiers (oxc-project#15717) (overlookmotel) - d8d4e31 ast: Use loop instead of recursion in `TSModuleDeclarationBody::as_module_block_mut` (oxc-project#15713) (overlookmotel) ### 📚 Documentation - e033d50 ast: Clarify behavior of `TSModuleDeclaration::has_use_strict_directive` (oxc-project#15730) (overlookmotel) - 9eda70f allocator: Improve docs for `Address` methods (oxc-project#15697) (overlookmotel)

This is kind of a workaround. The target of this PR is to solve rolldown/rolldown#6879 and rolldown/rolldown#6880.
While the proper way to fix them is to use the proper
ModuleKind(described in rolldown/rolldown#7009),ModuleKind::Unambiguousdoesn't work as expected and is blocked by #15541.So for the meanwhile, this PR can solve those issues indirectly. We can revert this PR once the issues above are solved properly, but I guess it's also fine to keep it as I think there's less value to remove
use strictdirectives in DCE.