Skip to content

Conversation

@camc314
Copy link
Contributor

@camc314 camc314 commented Dec 18, 2025

fixes #16893
fixes #16894

Copy link
Contributor Author

camc314 commented Dec 18, 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.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@github-actions github-actions bot added A-minifier Area - Minifier C-bug Category - Bug labels Dec 18, 2025
@camc314 camc314 marked this pull request as ready for review December 18, 2025 23:07
Copilot AI review requested due to automatic review settings December 18, 2025 23:07
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 extends the minifier's unused declaration removal functionality to handle import source and import defer statements, which are newer import phase proposals. When these imports are determined to be unused, they are completely removed (converted to empty statements) rather than converted to side-effect imports, since phase imports have specific semantics.

Key Changes

  • Added logic to detect and remove unused import source/defer statements when the imported binding is not referenced
  • Added comprehensive test coverage for both import source and import defer scenarios

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

@codspeed-hq
Copy link

codspeed-hq bot commented Dec 18, 2025

CodSpeed Performance Report

Merging #17085 will not alter performance

Comparing c/12-18-fix_minifier_remove_unused_import_source_defer_statements (743488a) with main (fb9e193)1

Summary

✅ 38 untouched
⏩ 7 skipped2

Footnotes

  1. No successful run was found on main (1cc4253) during the generation of this report, so fb9e193 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.

@camc314 camc314 force-pushed the c/12-18-fix_minifier_remove_unused_import_source_defer_statements branch from 5ef1052 to 743488a Compare December 18, 2025 23:12

let Statement::ImportDeclaration(import_decl) = stmt else { return };

if import_decl.phase.is_some() {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if import_decl.phase.is_some() {
if let Some(phase) = import_decl.phase {
let (ImportPhase::Defer | ImportPhase::Source) = phase;

I'm not sure if this is idiomatic, but I think it'd be nice to have this check so that we notice we have to verify the condition here when a new phase is added.

"",
&options,
);
test_same_options("import defer * as a from 'a'; foo(a.bar);", &options);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
test_same_options("import defer * as a from 'a'; foo(a.bar);", &options);
test_same_options("import defer * as a from 'a'; foo(a);", &options);
test_same_options("import defer * as a from 'a'; foo(a.bar);", &options);

@sapphi-red sapphi-red changed the title fix(minifier): remove unused import source/defer statements feat(minifier): remove unused import source/defer statements Dec 19, 2025
@github-actions github-actions bot added the C-enhancement Category - New feature or request label Dec 19, 2025
@sapphi-red sapphi-red removed the C-bug Category - Bug label Dec 19, 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.

minifier: remove unused import source statements minifier: remove unused specifiers from import defer statements

3 participants