Skip to content

[Bug]: Inlining an undefined variable produces longer output #10174

Description

@GulgDev

Reproduction link or steps

https://repl.rolldown.rs/#eNptkt1ugzAMhV/Fyk1bqaO7ZtrV3mFXXDQNpngLDkpMf4R49zmwdqtUBAIfx584JxlNY8rRENd4Kb5S/mZT/tVb47T0KDCo1BBj/WnjWxUrzg9e+hAFcv9k/YBz41dsBnZCgSFiQllvYMxNWBbC+yMQdjvY/1f2cERJQOyzAJZr5fTeOi3OJC3sT4FqeN1vF+rzS6nnllwLlMAHPmIEaS2DhcD44lobrRMVqUYWaghjpk1qG00pccBpa2Lwvg5nLlzgho6F3FN60lnyom5OYITFz8fchgmaGDpY3cZWmuEtLF1oBz+/7wPrMRsj7gcpYUEWHYotZmmbzUmL0JDHBAk9qpUaDtdZPQwimr3eaNW/2EOG6Ujo86akXIVBZvYIHTE11xKyZZg0gU3FRr331n3bI+pJCGp4cf2gLX7nH61MjT3qFrIjTJVRbiZlkJJO+RhZwSRm+gGSI9el

What is expected?

An almost intact version of the source with just mangled names and removed whitespace would be shorter:

let e,t;function n(){t=e}export{n as reset,t as value};

What is actually happening?

However, Rolldown inlined the variable and replaces it with undefined/void 0 which is 5 characters longer:

let e;function t(){e=void 0}export{t as reset,e as value};

System Info

System:
    OS: Windows 10 10.0.19045
    CPU: (16) x64 AMD Ryzen 7 5800X 8-Core Processor             
    Memory: 41.89 GB / 63.91 GB
  Binaries:
    Node: 24.5.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.22 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
    npm: 11.5.1 - C:\Program Files\nodejs\npm.CMD
    pnpm: 11.5.3 - C:\Program Files\nodejs\pnpm.CMD
    Deno: 2.5.4 - C:\Users\user\.deno\bin\deno.EXE
  Browsers:
    Chrome: 149.0.7827.201
    Edge: Chromium (150.0.4078.48)
    Firefox: 152.0 - C:\Program Files\Mozilla Firefox\firefox.exe
    Internet Explorer: 11.0.19041.5794
  npmPackages:
    rolldown: ^1.1.4 => 1.1.4

Any additional comments?

While this is not critical, it would make sense to at least introduce an option to control that behavior.

Metadata

Metadata

Assignees

Type

Fields

Priority

None yet

Effort

None yet

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions