Skip to content

[Bug]: improve DCE to remove code that relies on the value of itself #6945

Description

@benmccann

Reproduction link or steps

let hydrating = false;
let mismatch = false;

function set_hydrating(h) {
	hydrating = h;
}

if (hydrating) {
	mismatch = true;
}

if (mismatch) {
	set_hydrating(true);
}

if (hydrating) {
	console.log("Look ma! I'm hydrating!");
}

There's a more complex reproduction from a real project in vitejs/vite#21944, but I've tried to extract out a minimal reproduction

What is expected?

Rollup dead code eliminates everything in this file

What is actually happening?

Rollup leaves it

System Info

Rolldown 1.0.0-beta.49

Any additional comments?

No response

Metadata

Metadata

Assignees

Fields

Priority

None yet

Start date

None yet

Target date

None yet

Effort

None yet

Projects

Status
Backlog

Relationships

None yet

Development

No branches or pull requests

Issue actions