Skip to content

Replace unused pure call expressions with their side-effectful arguments #3144

@Andarist

Description

@Andarist

I've noticed this when testing treeshakeability of a some library that this input code~:

const create = () => {
  throw new Error('test')
}

/* #__PURE__ */ create({
  foo: create({}),
});

pretty much stays in the output, while when using Terser the outer call (the one annotated with PURE) gets eliminated. The inner call makes the difference here, because if we annotate it the whole thing just vanishes in both cases (as expected).

Expected Behavior

Matching behavior to Terser

Actual Behavior

Different behavior from Terser

Repro

REPL repro


Note from maintainer (@lukastaegert) :
The consensus on this issue is that even though the current behaviour is acceptable, it would be nice to replace call expressions with just their side-effectful arguments in certain cases. If someone wants to work towards a PR to improve this, see #3144 (comment) for implementation suggestions.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions