feat(minifier): default invalid_import_side_effects to false#18916
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 this PR will not alter performanceComparing Summary
Footnotes
|
There was a problem hiding this comment.
Pull request overview
This PR changes the default value of the invalid_import_side_effects option from true to false, aligning oxc's minifier behavior with industry-standard tools like Rollup, esbuild, and SWC. This option controls whether unused imports are preserved due to potential side effects from invalid imports (which would throw errors at runtime).
Changes:
- Updated default value of
invalid_import_side_effectsfromtruetofalseinTreeShakeOptions - Added test cases to cover both the new default behavior (removing unused imports) and the old behavior (preserving unused imports when
invalid_import_side_effects: true) - Updated memory allocation snapshot reflecting fewer system reallocs with the new default
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| crates/oxc_minifier/src/options.rs | Changed invalid_import_side_effects default from true to false and updated documentation |
| crates/oxc_minifier/tests/peephole/remove_unused_declaration.rs | Updated tests to use new default and added test cases for old behavior with explicit invalid_import_side_effects: true |
| tasks/track_memory_allocations/allocs_minifier.snap | Updated memory allocation metrics showing reduced reallocs (3→0) for RadixUIAdoptionSection.jsx |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Merge activity
|
) These sideeffects are commonly ignored, so I think we should ignore them by default. - [Rollup REPL](https://rollupjs.org/repl/?version=4.57.1&shareable=eyJleGFtcGxlIjpudWxsLCJtb2R1bGVzIjpbeyJjb2RlIjoiaW1wb3J0IHsgZm9vIH0gZnJvbSAndW5rbm93bidcbmlmIChmYWxzZSkge1xuICBjb25zb2xlLmxvZyhmb28pXG59IiwiaXNFbnRyeSI6dHJ1ZSwibmFtZSI6Im1haW4uanMifV0sIm9wdGlvbnMiOnt9fQ==) - [esbuild try](https://esbuild.github.io/try/#dAAwLjI3LjIALS1taW5pZnkAaW1wb3J0IHsgZm9vIH0gZnJvbSAndW5rbm93bicKaWYgKGZhbHNlKSB7CiAgY29uc29sZS5sb2coZm9vKQp9) - [SWC playground](https://play.swc.rs/?version=1.15.11&code=H4sIAAAAAAAAAw3LMQ6AIBAEwP6S%2B8N2YOOfjOEMEW4NaCwIf9fpJ9eL7caAkZiwxorw%2BOl8PahkQ7St9LRgqAA7vbOktfCI%2F1hUpsoHV0iLrEQAAAA%3D&config=H4sIAAAAAAAAA41VS47bMAzd5xSB111MB0VR9ADd9QyCYlGOMrJoiFQ%2BGOTupRU7k5nQRjdBzKdHiuQj9b7ZbpsDtc3v7bv8lY%2FBZoJ8%2FxYLXRLbs1gaaHtLbQ4DN99m9EAj5G0kqKbrDWnY5g64suj15fXHxGgiIsHMmGx9SMFfHmO22A8ZiB5sYhWXpYfE9Jk%2FYRlPI8C5PNp3iBFsWkGMJRMSQwdZc9xijHYgMEebFS%2FjTW0OhFqIESwMzgwZBxVPLnDAJDGfUQfWmRYdKFDI0HI4gkaTWEJLJOkp%2BVTYwa50Xe3zFzYcbSyWlZhwri2R2ype9xiIjS9JK%2BENXKjBDZyK%2B5UZvMnAJadn3gFDWujJG4BUIFqiZHvQ%2FNYTXvS0xParzJC8SJYvCi761rJM0ElRTQheqexYGcgctG5mcKWFsbKtdp0JXigfBQcGvBetKK7pFLjda0H5MgB6BZD%2BWq%2Bp6gaY%2BxQu4ONArMB%2FJEvWBTad6C3vl1G69DuMKwF64D26lQPSCsZlOMuWOA%2FLeEkORBrg1COFKvC8BGQAGE2s%2B%2FJJGzIe4tF0EXcfa2I6cL3v4d6mrs77w75kHCIcIS7J%2BD9GZBWVux1HVc%2BT%2FTS98EsTpZXBC99fPj0bkspm%2Fq1JNT268pBQ1eTtOfnZfByaX465ak2gvzNRKv6W8JSazfUfly9ihugGAAA%3D) This was originally set to `true` (#17300) for Rolldown (rolldown/rolldown#7512 (comment)), but that should be instead handled on Rolldown side (rolldown/rolldown#8194).
28b5208 to
742ad3f
Compare
### 💥 BREAKING CHANGES - 2bf7293 mangler: [**BREAKING**] Enable `top_level` by default for modules and commonjs (#18278) (sapphi-red) - 48b0542 span: [**BREAKING**] SourceType::ts should set module to unambigious (#18873) (Boshen) ### 🚀 Features - 500d071 minifier: Local traverse ctx and generated minifier traverse (#19106) (Boshen) - 142a1be parser: Detect binary files with TS1490 error (#19047) (Boshen) - e316857 allocator/bitset: Add `Ones` iterator to `BitSet` (#19027) (sapphi-red) - 742ad3f minifier: Default `invalid_import_side_effects` to `false` (#18916) (sapphi-red) - 0eff6be parser: Error JSX-like type assertions and generics in `.mts`/`.cts` (#18910) (Boshen) - 18320c6 span: Store file extension in `SourceType` (#18893) (Boshen) ### 🐛 Bug Fixes - a7514e4 isolated-declarations: Preserve const context in literal type inference (#19178) (camc314) - 312e756 isolated-declarations: Preserve readonly literal initializers (#19177) (camc314) - d0ca8d0 isolated-declarations: Skip parenthesis when inferring type (#19176) (camc314) - 110c300 oxc_ecmascript: `+[false]` and `+[true]` should evaluate to `NaN` (#19174) (copilot-swe-agent) - f32ea19 semantic: Report redeclaration error for import bindings conflicting with value declarations (#19068) (Boshen) - 3aeba7a semantic: Report redeclaration error for `function a() {} var a` in module mode (#19041) (Boshen) - 35e32c6 coverage: Match Babel's options.json inheritance for test fixtures (#19002) (Boshen) - 463d60d semantic: Skip TS2391 for standalone computed-name class methods (#19025) (Boshen) - 56c086b parser: Add modifier ordering validation (TS1029) (#19024) (Boshen) - 6067a49 linter/jsdoc: False positive in `check-tag-names` for `@` in email addresses and npm scopes (#19021) (Boshen) - b13bb70 semantic/jsdoc: Inline tags like `{@link}` break jsdoc parsing (#19019) (Boshen) - e3609e3 regular_expression: Preserve UnicodeEscape CharacterKind in string literals (#18998) (Boshen) - 57917ee parser: Parse decorators on rest parameters (#18938) (Boshen) - 487601b napi: Disable mimalloc on Windows to fix worker_threads crash (#18923) (Boshen) - 1f6b193 parser: Validate TypeScript import type options (#18889) (Boshen) - 1663184 parser: Allow conditional types in function type parameters (#18886) (Boshen) - 5758046 parser: Error on property access after instantiation expression (#18887) (Boshen) - 5eb4a94 parser: Handle `<<` as two `<` tokens in type argument contexts (#18885) (Boshen) ### ⚡ Performance - ed8c054 oxc_str: Add precomputed hash to Ident for fast HashMap lookups (#19143) (Boshen) - d4a0867 transformer_plugins: Switch ReplaceGlobalDefines from Traverse to VisitMut (#19146) (Boshen) - 9eb16b3 syntax: Pack ASCII identifier tables into single bitflag table (#19088) (Boshen) - e7595d1 mangler: Use BitSet for exported symbols set (#19023) (sapphi-red) - 2537924 semantic: Optimize scope resolution with fast paths and inlining (#19029) (Boshen) - 69a8d85 mangler: Use BitSet for keep_names symbols set (#19028) (sapphi-red) - f78c525 parser: Try hybrid parsing for jsx children and closing element/fragments (#18789) (camchenry) Co-authored-by: camc314 <[email protected]>
### 💥 BREAKING CHANGES - 2bf7293 mangler: [**BREAKING**] Enable `top_level` by default for modules and commonjs (oxc-project#18278) (sapphi-red) - 48b0542 span: [**BREAKING**] SourceType::ts should set module to unambigious (oxc-project#18873) (Boshen) ### 🚀 Features - 500d071 minifier: Local traverse ctx and generated minifier traverse (oxc-project#19106) (Boshen) - 142a1be parser: Detect binary files with TS1490 error (oxc-project#19047) (Boshen) - e316857 allocator/bitset: Add `Ones` iterator to `BitSet` (oxc-project#19027) (sapphi-red) - 742ad3f minifier: Default `invalid_import_side_effects` to `false` (oxc-project#18916) (sapphi-red) - 0eff6be parser: Error JSX-like type assertions and generics in `.mts`/`.cts` (oxc-project#18910) (Boshen) - 18320c6 span: Store file extension in `SourceType` (oxc-project#18893) (Boshen) ### 🐛 Bug Fixes - a7514e4 isolated-declarations: Preserve const context in literal type inference (oxc-project#19178) (camc314) - 312e756 isolated-declarations: Preserve readonly literal initializers (oxc-project#19177) (camc314) - d0ca8d0 isolated-declarations: Skip parenthesis when inferring type (oxc-project#19176) (camc314) - 110c300 oxc_ecmascript: `+[false]` and `+[true]` should evaluate to `NaN` (oxc-project#19174) (copilot-swe-agent) - f32ea19 semantic: Report redeclaration error for import bindings conflicting with value declarations (oxc-project#19068) (Boshen) - 3aeba7a semantic: Report redeclaration error for `function a() {} var a` in module mode (oxc-project#19041) (Boshen) - 35e32c6 coverage: Match Babel's options.json inheritance for test fixtures (oxc-project#19002) (Boshen) - 463d60d semantic: Skip TS2391 for standalone computed-name class methods (oxc-project#19025) (Boshen) - 56c086b parser: Add modifier ordering validation (TS1029) (oxc-project#19024) (Boshen) - 6067a49 linter/jsdoc: False positive in `check-tag-names` for `@` in email addresses and npm scopes (oxc-project#19021) (Boshen) - b13bb70 semantic/jsdoc: Inline tags like `{@link}` break jsdoc parsing (oxc-project#19019) (Boshen) - e3609e3 regular_expression: Preserve UnicodeEscape CharacterKind in string literals (oxc-project#18998) (Boshen) - 57917ee parser: Parse decorators on rest parameters (oxc-project#18938) (Boshen) - 487601b napi: Disable mimalloc on Windows to fix worker_threads crash (oxc-project#18923) (Boshen) - 1f6b193 parser: Validate TypeScript import type options (oxc-project#18889) (Boshen) - 1663184 parser: Allow conditional types in function type parameters (oxc-project#18886) (Boshen) - 5758046 parser: Error on property access after instantiation expression (oxc-project#18887) (Boshen) - 5eb4a94 parser: Handle `<<` as two `<` tokens in type argument contexts (oxc-project#18885) (Boshen) ### ⚡ Performance - ed8c054 oxc_str: Add precomputed hash to Ident for fast HashMap lookups (oxc-project#19143) (Boshen) - d4a0867 transformer_plugins: Switch ReplaceGlobalDefines from Traverse to VisitMut (oxc-project#19146) (Boshen) - 9eb16b3 syntax: Pack ASCII identifier tables into single bitflag table (oxc-project#19088) (Boshen) - e7595d1 mangler: Use BitSet for exported symbols set (oxc-project#19023) (sapphi-red) - 2537924 semantic: Optimize scope resolution with fast paths and inlining (oxc-project#19029) (Boshen) - 69a8d85 mangler: Use BitSet for keep_names symbols set (oxc-project#19028) (sapphi-red) - f78c525 parser: Try hybrid parsing for jsx children and closing element/fragments (oxc-project#18789) (camchenry) Co-authored-by: camc314 <[email protected]>
### 💥 BREAKING CHANGES - 2bf7293 mangler: [**BREAKING**] Enable `top_level` by default for modules and commonjs (oxc-project#18278) (sapphi-red) - 48b0542 span: [**BREAKING**] SourceType::ts should set module to unambigious (oxc-project#18873) (Boshen) ### 🚀 Features - 500d071 minifier: Local traverse ctx and generated minifier traverse (oxc-project#19106) (Boshen) - 142a1be parser: Detect binary files with TS1490 error (oxc-project#19047) (Boshen) - e316857 allocator/bitset: Add `Ones` iterator to `BitSet` (oxc-project#19027) (sapphi-red) - 742ad3f minifier: Default `invalid_import_side_effects` to `false` (oxc-project#18916) (sapphi-red) - 0eff6be parser: Error JSX-like type assertions and generics in `.mts`/`.cts` (oxc-project#18910) (Boshen) - 18320c6 span: Store file extension in `SourceType` (oxc-project#18893) (Boshen) ### 🐛 Bug Fixes - a7514e4 isolated-declarations: Preserve const context in literal type inference (oxc-project#19178) (camc314) - 312e756 isolated-declarations: Preserve readonly literal initializers (oxc-project#19177) (camc314) - d0ca8d0 isolated-declarations: Skip parenthesis when inferring type (oxc-project#19176) (camc314) - 110c300 oxc_ecmascript: `+[false]` and `+[true]` should evaluate to `NaN` (oxc-project#19174) (copilot-swe-agent) - f32ea19 semantic: Report redeclaration error for import bindings conflicting with value declarations (oxc-project#19068) (Boshen) - 3aeba7a semantic: Report redeclaration error for `function a() {} var a` in module mode (oxc-project#19041) (Boshen) - 35e32c6 coverage: Match Babel's options.json inheritance for test fixtures (oxc-project#19002) (Boshen) - 463d60d semantic: Skip TS2391 for standalone computed-name class methods (oxc-project#19025) (Boshen) - 56c086b parser: Add modifier ordering validation (TS1029) (oxc-project#19024) (Boshen) - 6067a49 linter/jsdoc: False positive in `check-tag-names` for `@` in email addresses and npm scopes (oxc-project#19021) (Boshen) - b13bb70 semantic/jsdoc: Inline tags like `{@link}` break jsdoc parsing (oxc-project#19019) (Boshen) - e3609e3 regular_expression: Preserve UnicodeEscape CharacterKind in string literals (oxc-project#18998) (Boshen) - 57917ee parser: Parse decorators on rest parameters (oxc-project#18938) (Boshen) - 487601b napi: Disable mimalloc on Windows to fix worker_threads crash (oxc-project#18923) (Boshen) - 1f6b193 parser: Validate TypeScript import type options (oxc-project#18889) (Boshen) - 1663184 parser: Allow conditional types in function type parameters (oxc-project#18886) (Boshen) - 5758046 parser: Error on property access after instantiation expression (oxc-project#18887) (Boshen) - 5eb4a94 parser: Handle `<<` as two `<` tokens in type argument contexts (oxc-project#18885) (Boshen) ### ⚡ Performance - ed8c054 oxc_str: Add precomputed hash to Ident for fast HashMap lookups (oxc-project#19143) (Boshen) - d4a0867 transformer_plugins: Switch ReplaceGlobalDefines from Traverse to VisitMut (oxc-project#19146) (Boshen) - 9eb16b3 syntax: Pack ASCII identifier tables into single bitflag table (oxc-project#19088) (Boshen) - e7595d1 mangler: Use BitSet for exported symbols set (oxc-project#19023) (sapphi-red) - 2537924 semantic: Optimize scope resolution with fast paths and inlining (oxc-project#19029) (Boshen) - 69a8d85 mangler: Use BitSet for keep_names symbols set (oxc-project#19028) (sapphi-red) - f78c525 parser: Try hybrid parsing for jsx children and closing element/fragments (oxc-project#18789) (camchenry) Co-authored-by: camc314 <[email protected]>

These sideeffects are commonly ignored, so I think we should ignore them by default.
This was originally set to
true(#17300) for Rolldown (rolldown/rolldown#7512 (comment)), but that should be instead handled on Rolldown side (rolldown/rolldown#8194).