fix: add declaration for unused harmony import specifier by hai-x · Pull Request #20286 · webpack/webpack

Summary

What kind of change does this PR introduce?

Fixes #20151 and fixes #20276.

We will generate a var declaration (i.e. var unused_import_specifier) for unused import specifiers to reduce the likelihood of the entry module being wrapped in an IIFE.

Notably, the declaration will be safely removed after minimize, so i think the pros outweigh the costs.

Did you add tests for your changes?

Yes

Does this PR introduce a breaking change?

No

If relevant, what needs to be documented once your changes are merged or what have you already documented?

No