Skip to content

minifier: does not eliminate unnecessary side-effect free function call #13027

@TheAlexLichter

Description

@TheAlexLichter

Case

When a side-effect free function is called multiple times, the call could be removed. Same applies to unused variables assigned to the result of the side-effect free function

Reproduction

Expected output

function foo() {
  return !0
}

const a = foo();

console.log(a);

or a smaller version like - though above would suffice for now.

```ts
function foo() {
  return !0
}

console.log(foo());

Actual output

function foo() {
	return !0;
}
const a = foo();
foo(), foo(), console.log(a);

Info

Originally reported in rolldown/rolldown#5712

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions