Skip to content

feat(minifier): add invalid_import_side_effects option#17300

Merged
graphite-app[bot] merged 1 commit intomainfrom
12-23-feat_minifier_add_invalid_import_side_effects_option
Dec 23, 2025
Merged

feat(minifier): add invalid_import_side_effects option#17300
graphite-app[bot] merged 1 commit intomainfrom
12-23-feat_minifier_add_invalid_import_side_effects_option

Conversation

@sapphi-red
Copy link
Member

@sapphi-red sapphi-red commented Dec 23, 2025

Added a new option (invalid_import_side_effects) to disable #16797 as it requires a new assumptions.

refs rolldown/rolldown#7512 (comment)

@github-actions github-actions bot added A-minifier Area - Minifier C-enhancement Category - New feature or request labels Dec 23, 2025
Copy link
Member Author


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.

@codspeed-hq
Copy link

codspeed-hq bot commented Dec 23, 2025

CodSpeed Performance Report

Merging #17300 will not alter performance

Comparing 12-23-feat_minifier_add_invalid_import_side_effects_option (442fb1c) with main (8f96146)1

Summary

✅ 38 untouched
⏩ 7 skipped2

Footnotes

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

  2. 7 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@sapphi-red sapphi-red force-pushed the 12-23-feat_minifier_add_invalid_import_side_effects_option branch from 494bd15 to 732dd69 Compare December 23, 2025 04:56
@sapphi-red sapphi-red marked this pull request as ready for review December 23, 2025 05:02
Copilot AI review requested due to automatic review settings December 23, 2025 05:02
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 a new invalid_import_side_effects option to the minifier to control whether unused import removal optimization should be performed. The option allows users to disable the optimization introduced in #16797, as it requires additional assumptions about import behavior. When set to true (default), imports are preserved because accessing non-existing imports or unresolved import statements can throw errors. When set to false, unused imports can be safely removed.

Key Changes:

  • Added invalid_import_side_effects option with default value of true to preserve backward compatibility
  • Integrated the option into the import removal logic to gate the optimization
  • Updated tests to explicitly set the option when testing import removal behavior

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
crates/oxc_minifier/src/options.rs Added invalid_import_side_effects field to TreeShakeOptions struct with default value of true
crates/oxc_minifier/src/peephole/remove_unused_declaration.rs Integrated the new option into import removal logic; updated tests to explicitly disable the option when testing removal behavior
napi/minify/src/options.rs Added NAPI binding for the new option with proper type conversion
napi/minify/index.d.ts Added TypeScript definition for invalidImportSideEffects option
tasks/track_memory_allocations/allocs_minifier.snap Updated memory allocation snapshot reflecting minimal overhead from the new option check

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@sapphi-red sapphi-red requested a review from Boshen December 23, 2025 05:21
@Boshen Boshen added the 0-merge Merge with Graphite Merge Queue label Dec 23, 2025
Copy link
Member

Boshen commented Dec 23, 2025

Merge activity

Added a new option (`invalid_import_side_effects`) to disable #16797 as it requires a new assumptions.

refs rolldown/rolldown#7512 (comment)
@graphite-app graphite-app bot force-pushed the 12-23-feat_minifier_add_invalid_import_side_effects_option branch from 442fb1c to 8e4409a Compare December 23, 2025 09:49
@graphite-app graphite-app bot merged commit 8e4409a into main Dec 23, 2025
20 checks passed
@graphite-app graphite-app bot deleted the 12-23-feat_minifier_add_invalid_import_side_effects_option branch December 23, 2025 09:56
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Dec 23, 2025
graphite-app bot pushed a commit that referenced this pull request Feb 4, 2026
)

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).
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